[LLVMbugs] [Bug 15048] New: bad code for struct initialization on x86
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Jan 22 22:11:33 PST 2013
http://llvm.org/bugs/show_bug.cgi?id=15048
Bug #: 15048
Summary: bad code for struct initialization on x86
Product: clang
Version: unspecified
Platform: PC
OS/Version: All
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: dhazeghi at yahoo.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
We've found the following snippet (derived from 931004-11.c in the gcc
testsuite) which produces incorrect results with clang 3.2 and trunk when
compiled for x86_64-linux in 32-bit mode, using -O3. At lower optimization
levels, the output is correct. This may be connected to bug #14972, although
it triggers only at -O3, unlike that bug.
$ cat reduced.c
#include <stdio.h>
struct tiny {
unsigned char c;
unsigned char d;
unsigned char e;
};
void foo (struct tiny x, struct tiny y, struct tiny z) {
if (x.c != 1)
printf("BUG1\n");
if (x.e != 1)
printf("BUG2\n");
if (y.c != 1)
printf("BUG3\n");
if (y.d != 1)
printf("BUG4\n");
if (z.c != 1)
printf("BUG5\n");
}
int main (void) {
struct tiny x[3];
x[0].c = 1;
x[1].c = 1;
x[2].c = 1;
x[0].d = 1;
x[1].d = 1;
x[2].d = 1;
x[0].e = 1;
x[1].e = 1;
x[2].e = 1;
foo (x[0], x[1], x[2]);
printf("END\n");
return 0;
}
$ clang -O2 -m32 reduced.c
$ ./a.out
END
$ clang -O3 -m32 reduced.c
$ ./a.out
BUG1
BUG2
END
--
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