[Bug tree-optimization/102446] New: wrong code at -O3 on x86_64-linux-gnu
zhendong.su at inf dot ethz.ch
gcc-bugzilla@gcc.gnu.org
Wed Sep 22 09:00:55 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446
Bug ID: 102446
Summary: wrong code at -O3 on x86_64-linux-gnu
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zhendong.su at inf dot ethz.ch
Target Milestone: ---
This seems to be a long-latent miscompilation, affecting GCC 5.1 and later.
[583] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++
--disable-werror --enable-multilib --with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210922 (experimental) [master r12-3777-g578b7687338] (GCC)
[584] %
[584] % gcctk -O2 small.c; ./a.out
[585] %
[585] % gcctk -O3 small.c
[586] % ./a.out
Segmentation fault
[587] %
[587] % cat small.c
int a = 1, c, e, f, *j, k, o, *r = &f, s;
char b, l;
short d, *g;
unsigned h;
static void m(void);
static void n(int);
void p(int *q) {
while (1) {
if (*q)
break;
if (*g)
o = c;
while (l)
;
}
}
void t() {
for (; s < 8; s++)
m();
}
void m() {
int aa = 0, i = 0;
for (; i < 3; i++)
if (k < 0)
aa |= *j;
if (d)
c = (h + *g + 2) & c;
n(aa);
}
void n(int ac) {
char *ad = &b, u = ac, *v = &b;
int ae = *ad = a;
u && (*v = e > 0);
*r = c;
p(&ae);
}
int main() {
t();
return 0;
}
More information about the Gcc-bugs
mailing list