http://llvm.org/bugs/show_bug.cgi?id=10342
Summary: apparent wrong code bug at -O0
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: All
Status: NEW
Severity: normal
Priority: P
Component: new bugs
AssignedTo: [email protected]
ReportedBy: [email protected]
CC: [email protected]
I believe the correct result of the program below is "0" because the unsigned
bit field is promoted to signed int before comparison.
In fact, Clang prints 0 if the comma operator is removed. I think that
clinches it.
[regehr@gamow ~]$ clang -v
clang version 3.0 (trunk 134918)
Target: x86_64-unknown-linux-gnu
Thread model: posix
[regehr@gamow ~]$ clang -O0 small.c
small.c:11:17: warning: expression result unused [-Wunused-value]
int y = x >= (0, s.f1);
^
1 warning generated.
[regehr@gamow ~]$ ./a.out
1
[regehr@gamow ~]$ cat small.c
#include <stdio.h>
struct S0 {
unsigned f1:1;
};
struct S0 s;
int main (void) {
int x = -3;
int y = x >= (0, s.f1);
printf ("%d\n", y);
return 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