[LLVMbugs] [Bug 16462] New: wrong code at optimization levels -Os and above

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jun 25 23:51:26 PDT 2013


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

            Bug ID: 16462
           Summary: wrong code at optimization levels -Os and above
           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 current clang trunk and 3.3 on
x86_64-linux-gnu at -Os and above (in both 32-bit and 64-bit modes). This is a
regression from 3.2. 

$ clang-trunk -v
clang version 3.4 (trunk 184829)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang-trunk -O1 reduced.c
$ a.out
1
$ clang-trunk -Os reduced.c
$ a.out
0
$ clang-3.3 -Os reduced.c
$ a.out
0
$ clang-3.2 -Os reduced.c
$ a.out
1
$ 

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

int printf (const char *, ...);

static short fn1 (int p)
{
  return p ? 0 : 1;
}

unsigned short fn2 (int p)
{
  return -p;
}

int a[1], b, *c = &b, d; 

void fn3 ()
{
  int *t = &d;
  if (fn2(1) >= fn1 (t == &a[0])) 
    *c = 1;
}

int main ()
{
  fn3 ();
  printf ("%d\n", b);
  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/20130626/1e08ee6f/attachment.html>


More information about the llvm-bugs mailing list