[LLVMbugs] [Bug 2959] New: Miscompilation of expression with multiple side-effects
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Mon Oct 27 09:58:05 PDT 2008
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: unassignedbugs at nondot.org
ReportedBy: richard at xmos.com
CC: llvmbugs at cs.uiuc.edu
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.
More information about the llvm-bugs
mailing list