http://llvm.org/bugs/show_bug.cgi?id=2959

           Summary: Miscompilation of expression with multiple side-effects
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: llvm-gcc
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [email protected]


Created an attachment (id=2141)
 --> (http://llvm.org/bugs/attachment.cgi?id=2141)
Resulting bitcode

When the following code is compiled with llvm-gcc and run

int *p;

int f() {
        (*p)++;
        return 1;
}

int main() {
        int b;
        p = &b;
        b++ + f();
        return (b == 2) ? 0 : 1;
}

it returns 1. Even though the order of evaluation of the operands of add is
undefined, I believe the result is well defined since the call to f is a
sequence point. Either b++ is executed first in which case the increment of b
must complete before the call to f() or f() is executed first in which case the
increment of (*p) must complete by the end of the 1st statement in f(). Either
way b should end up with the value 2, giving an expected return value of 0.


-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to