[llvm-bugs] [Bug 36629] New: Clang miscompiles with -O0.
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Mar 7 05:02:30 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36629
Bug ID: 36629
Summary: Clang miscompiles with -O0.
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
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 20013
--> https://bugs.llvm.org/attachment.cgi?id=20013&action=edit
Reproducer.
Reduced reproducer (see full in attachment):
>$ cat repr.cpp
#include <stdio.h>
#include <vector>
struct struct_1 {
signed char member_1_0 : 23;
unsigned char : 16;
unsigned char member_1_1 : 25;
};
const unsigned char aa = 60;
const unsigned char bb = 246;
signed char cc = 36;
signed char dd = 97;
unsigned char ee = 178;
struct_1 struct_obj_1;
short a = 42;
void tf_0_foo() {
ee = a % (unsigned char)((bb && aa ? ~0 : 0) % struct_obj_1.member_1_0 ^ cc);
dd = struct_obj_1.member_1_1;
}
int main() {
struct_obj_1.member_1_0 = -122;
struct_obj_1.member_1_1 = 98;
tf_0_foo();
printf("%d\n", (int)ee);
}
Error:
>$ clang++ -fsanitize=undefined -fno-sanitize-recover=undefined -Werror=uninitialized -Werror=implicitly-unsigned-literal -O0 -w repr.cpp ; ./a.out
42
>$ clang++ -w -O0 repr.cpp ; ./a.out
5
LLVM version:
>$ clang++ -v
clang version 7.0.0 (trunk 326547)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /llvm/bin-trunk/bin
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/i686-redhat-linux/4.8.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/4.8.5
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
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/20180307/244b655e/attachment-0001.html>
More information about the llvm-bugs
mailing list