https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127764
Bug ID: 127764
Summary: Wrong code at -O2/3/s on x86_64-pc-linux-gnu
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: xintong.zhou1 at uwaterloo dot ca
Target Milestone: ---
Compiler Explorer: https://godbolt.org/z/T3TP36fdP
Note:
- fail: trunk, 10 - 16
- work: 9 or earlier
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=/data/x27zhou/compiler-nightly/install/gcc/bin/gcc
COLLECT_LTO_WRAPPER=/data/x27zhou/compiler-nightly/install/gcc/libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /data/x27zhou/compiler-nightly/src/gcc/configure CC='ccache
clang' CXX='ccache clang++' --enable-checking=yes --disable-bootstrap
--disable-multilib --enable-languages=c,c++
--prefix=/data/x27zhou/compiler-nightly/install/gcc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20261007 (experimental) (GCC)
$
$ gcc-trunk -O0 small.c && ./a.out
$ gcc-trunk -O2 small.c && ./a.out
[1] 2274086 illegal hardware instruction (core dumped) ./a.out
$
$ cat small.c
int b, c;
int d(int *p1) {
switch ((unsigned char)*p1)
case 1:
case 3:
case 255:
return 1 + b % 60;
return 0;
}
int main() {
int e[] = {255};
c = d(e);
}