[LLVMbugs] [Bug 14972] New: bad code for struct on x86

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed Jan 16 17:08:26 PST 2013


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

             Bug #: 14972
           Summary: bad code for struct on x86
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          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 fails with clang 3.2 and trunk when compiled for x86_64-linux
for 32-bits, using -O1 or higher optimizations, but works fine at -O0 or -Os:

$ clang -m32 -O reduced.c 
$ ./a.out 
Aborted (core dumped)
$ clang -m32 -O0 reduced.c 
$ ./a.out 
$ clang -v
clang version 3.3 (trunk 172630)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ cat reduced.c 
#include <stdlib.h>

struct tiny
{
  char c;
  char d; 
  char e;
};

void foo (struct tiny x)
{
  if (x.c != 1)
    abort();

  if (x.e != 1)
    abort();
}

int main ()
{
  struct tiny s;

  s.c = 1; 
  s.d = 1;
  s.e = 1;

  foo(s);

  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.



More information about the llvm-bugs mailing list