https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85588
Bug ID: 85588 Summary: -fwrapv miscompilation Product: gcc Version: 9.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: kristerw at gcc dot gnu.org Target Milestone: --- GCC miscompiles gcc/testsuite/gcc.dg/torture/pr57656.c when using -fwrapv > gcc -fwrapv pr57656.c > ./a.out Abort (core dumped) The problem seems to be exactly the same as in PR57656 (but when using -fwrapv): t = 1 - ((a - b) / c); is changed to t = (b - a) / c + 1; which is not the same in this case where both (a - b) and (b - a) have the value 0x80000000. This fails in GCC 6 and newer versions. Compiling using GCC 5 produces the correct result.