https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68067
Bug ID: 68067 Summary: Wrong constant folding Product: gcc Version: trans-mem Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ishiura-compiler at ml dot kwansei.ac.jp Target Milestone: --- GCC-6.0.0 miscompiles the following code. GCC-4.3.6 or later versions miscompile too. $cat error.c int main(void) { int a = -1; static int b = -2147483647 - 1; static int c = 0; int t = a - (b - c); if (t != 2147483647) { __builtin_abort(); } return 0; } $gcc-6.0 error.c -O3 && ./a.out [1] 25603 abort (core dumped) ./a.out $gcc-6.0 -v Using built-in specs. COLLECT_GCC=gcc-6.0 COLLECT_LTO_WRAPPER=$HOME/opt/gcc-6.0.0/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc/configure --prefix=$HOME/opt/gcc-6.0.0 --enable-languages=c --disable-multilib --program-suffix=-6.0 Thread model: posix gcc version 6.0.0 20151022 (experimental) (GCC)