Re: Defect in linearization of short circuit &&

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christopher Li pisze:

EXPR_BINOP used in normal operation require two operands.
e.g.  a + b, a | b
Both operands will get evaluated.

EXPR_LOGICAL using for condition branching and it has the short curcit
behavior in mind. e.g. a || b

I found the offending block of code. It is in expand.c, in function expand_logical:

      /*
       * If the right side is safe and cheaper than a branch,
       * just avoid the branch and turn it into a regular binop
       * style SAFELOGICAL.
       */
      if (rcost < BRANCH_COST) {
              expr->type = EXPR_BINOP;
              rcost -= BRANCH_COST - 1;
      }

After removing these lines, everything works fine.

But I guess that there must have been a reason to add them in the first place. I see it checking the cost of the operation, but I don't know why somebody assumes that it would be safe not to make a branch. Does anybody know how to fix it without simply removing these lines?

Thanks!
Jacek
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux