https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123416
Bug ID: 123416
Summary: wrong code at -O{s,2,3} with "-fno-tree-dse
-fno-strict-aliasing" 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: ---
Compiler Explorer: https://godbolt.org/z/MdMzj15xz
Note:
- fail: 12.5, 13.4, 14.3, 15.1, 15.2, trunk
- at -O{s,2,3}
[506] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/16.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 16.0.0 20260106 (experimental) (GCC)
[507] %
[507] % gcctk -O3 small.c; ./a.out
[508] % gcctk -O3 -fno-tree-dse -fno-strict-aliasing small.c
[509] % ./a.out
Aborted
[510] % cat small.c
struct a {
int b;
} c;
int d;
static struct a g() {
int a[2], b, f = 0;
for (; f < 2; f++)
a[f] = 1;
b = a[0];
if (b)
return c;
}
int main() {
c.b = 1;
struct a e = g();
c = g();
if (!c.b)
__builtin_abort();
return 0;
}