This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/86886] New: Gcc miscompiles at -O3 on valid code
- From: "helloqirun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 08 Aug 2018 07:46:06 +0000
- Subject: [Bug tree-optimization/86886] New: Gcc miscompiles at -O3 on valid code
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86886
Bug ID: 86886
Summary: Gcc miscompiles at -O3 on valid code
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: helloqirun at gmail dot com
Target Milestone: ---
It also affects gcc-8.1 at -O3. gcc-6.1 works fine.
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/home/absozero/trunk/root-gcc/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/absozero/trunk/root-gcc
--enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
gcc version 9.0.0 20180807 (experimental) [trunk revision 263356] (GCC)
$ gcc-6.1 -O3 abc.c; ./a.out
0
$ gcc abc.c; ./a.out
0
$ gcc-8.1 -O3 abc.c; ./a.out
1
$ gcc-trunk -O3 abc.c; ./a.out
1
$ cat abc.c
void printf();
typedef int f;
short g, k, l, n;
union {
int b;
short c;
} h;
f d, e;
unsigned short *i = &h.c;
unsigned short **j = &i;
f *m = &d, *o = &h.b;
void p(f a) {
*o = 0;
for (; e;)
;
n = **j;
l = n;
unsigned char aq = n;
k = g == 0 ? aq : 0;
*m = k;
}
int main() {
**j = 1;
p(6);
printf("%d\n", d);
}