https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121589
Bug ID: 121589
Summary: wrong code at -O1 and above 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/4z8Y4o6MY
Note:
- works: 5.4 and earlier
- fails: 6.1 and later
- -fno-tree-slsr and -fno-ivopts do not make it disappear
[589] % 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 20250818 (experimental) (GCC)
[590] %
[590] % gcctk -O1 small.c
[591] % ./a.out
Aborted
[592] % cat small.c
int a(int b) {
int c[2] = {1, 0}, *d = &c[1], *e = d + b;
return *(e + 1);
}
int main() {
if (a(-2) != 1)
__builtin_abort();
return 0;
}