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: unassignedb...@nondot.org
Reporter: vsevolod.livins...@frtk.ru
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs