https://bugs.llvm.org/show_bug.cgi?id=35571
Bug ID: 35571
Summary: [Clang-optimization] wrong code for optimization the
union assignment in a called function
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: yangyib...@nju.edu.cn
CC: llvm-bugs@lists.llvm.org
$ clang -v
clang version 6.0.0-svn320088-1~exp1 (trunk)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.2.0
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.2.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ cat small.c
int printf(const char *, ...);
union {
int a;
short b;
} c, *d = &c, e = {1};
void f() {
c.a = 0;
*d = e;
c.b = 0;
}
int main() {
f();
printf("%d\n", c.b);
}
$ clang -O0 small.c; ./a.out
0
$ clang -Ofast small.c; ./a.out
1
When removing function f and put the three lines of code in the main function,
the output is the same.
--
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