[LLVMbugs] [Bug 17638] New: wrong code at -O1 and above (affecting all clang versions on x86_64-linux-gnu and MacOS X)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 21 12:20:42 PDT 2013


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

            Bug ID: 17638
           Summary: wrong code at -O1 and above (affecting all clang
                    versions on x86_64-linux-gnu and MacOS X)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: su at cs.ucdavis.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code is miscompiled by the current clang trunk (and older
versions) on x86_64-linux-gnu at -O1 and above in both 32-bit and 64-bit modes. 

It also affects MacOS X. 

$ clang-trunk -v
clang version 3.4 (trunk 193069)
Target: x86_64-pc-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.4.7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
$ 
$ clang-trunk -O0 small.c; a.out
$ 
$ clang-trunk -O1 small.c; a.out
Segmentation fault (core dumped)
$ clang-3.3 -O1 small.c; a.out
Segmentation fault (core dumped)
$ clang-3.2 -O1 small.c; a.out
Segmentation fault (core dumped)
$ clang-3.1 -O1 small.c; a.out
Segmentation fault (core dumped)
$ clang-3.0 -O1 small.c; a.out
Segmentation fault (core dumped)
$ 

---------------------------------

unsigned int a;
int b, d[2], e[1]; 
short c;

int
main ()
{
  for (; b < 1; b++)
    for (a = 0; a < 2; a++)
      {
    if (c < 2) 
      e[0] = e[b] < d[a]; 
    else
      break;
    for (c = 0; c >= 0; c--)
      ;
      }
  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131021/1d3999aa/attachment.html>


More information about the llvm-bugs mailing list