https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113709
Bug ID: 113709
Summary: User -fno-thread-jumps gave Floating point exception
at -O2, -O3, -Os
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: jiajing_zheng at 163 dot com
Target Milestone: ---
With -fno-thread-jumps option, GCC-12.2.0 at -O2, O3, -Os optimization levels
generated the 'Floating point exception (core dumped)' message.
jing@jing-ubuntu:~$ cat source.c
static unsigned int A = 20;
static unsigned int B = 1;
int main(void) {
int i;
for (i = 0; i < 2; i++) {
A *= (B / (A ? A : 3)) / (A ? A : 5);
}
return 0;
}
jing@jing-ubuntu:~$ gcc source.c -O0 -fno-thread-jumps && ./a.out
jing@jing-ubuntu:~$ gcc source.c -O1 -fno-thread-jumps && ./a.out
jing@jing-ubuntu:~$ gcc source.c -O2 -fno-thread-jumps && ./a.out
Floating point exception (core dumped)
jing@jing-ubuntu:~$ gcc source.c -O3 -fno-thread-jumps && ./a.out
Floating point exception (core dumped)
jing@jing-ubuntu:~$ gcc source.c -Os -fno-thread-jumps && ./a.out
Floating point exception (core dumped)
jing@jing-ubuntu:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/jing/gcc-12.2.0/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/12.2.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure -enable-checking=release -enable-languages=c,c++
-disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.2.0 (GCC)