[llvm-bugs] [Bug 32830] New: Clang produces incorrect code with -O2 and higher

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Apr 27 11:20:04 PDT 2017


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

            Bug ID: 32830
           Summary: Clang produces incorrect code with -O2 and higher
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: Vsevolod.Livinskij at frtk.ru
                CC: llvm-bugs at lists.llvm.org

Created attachment 18373
  --> https://bugs.llvm.org/attachment.cgi?id=18373&action=edit
Reproducer.

Reproducer:
>$ cat repr.c 
extern const long int var_47;
extern const long int var_53;
extern const long long int var_58;
extern long int var_579;

void foo() { 
    var_579 = ((var_58 | var_53) ^ ~var_58) & (var_47 | ~var_58);
}

>$ cat main.c 
#include <stdio.h>

extern void foo ();

const long int var_47 = 6664195969892517546L;
const long int var_53 = 1679594420099092216L;
const long long int var_58 = 1515497576132836640LL;
long int var_579 = -7475619439701949757L;

int main () {
    foo ();
    printf ("%ld\n", var_579);
    return 0;
}

Error:
>$ clang -O0 main.c repr.c; ./a.out 
-236191838907956185
>$ clang -O2 main.c repr.c; ./a.out 
-5292815780869864331

LLVM version:
>$ clang -vclang version 5.0.0 (trunk 301477)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/vsevolod/workspace/llvm/bin-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

-- 
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/20170427/f6b9de70/attachment.html>


More information about the llvm-bugs mailing list