[llvm-bugs] [Bug 26994] New: wrong code at -O1 and above in 32-bit mode on x86_64-linux-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Mar 19 02:02:22 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=26994

            Bug ID: 26994
           Summary: wrong code at -O1 and above in 32-bit mode on
                    x86_64-linux-gnu
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

The following code is miscompiled by the trunk at -O1 and above in 32-bit mode
on x86_64-linux-gnu.

This bug also affects clang-3.7 and later versions. 


$: clang-trunk -v
clang version 3.9.0 (trunk 263789)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.3.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$: 
$: clang-trunk small.c -O3 -m32 ; ./a.out ; echo $?
1
$: clang-trunk small.c -O1 -m32 ; ./a.out ; echo $?
1
$: clang-trunk small.c -O0 -m32 ; ./a.out ; echo $?
0
$: clang-3.7 small.c -O1 -m32 ; ./a.out ; echo $?
1
$: cat small.c
int main () {
    int *p = 0;
trick:
    if (p)
        return *p;
    int x = 0;
    p = &x;
    goto trick;
    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/20160319/fa7d3af2/attachment-0001.html>


More information about the llvm-bugs mailing list