https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84997
--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> --- On Tue, 20 Mar 2018, antoshkka at gmail dot com wrote: > For example > > int test2(int lhs) { > lhs += 2.0; > return lhs; > } That would need -fno-trapping-math, because if the addition results in a double value larger than INT_MAX, under Annex F the conversion back to int is defined to raise FE_INVALID along with producing an unspecified value. > int test2(int lhs) { > lhs += 2.000000000000001; > return lhs; > } That's not correct to optimize unless you generate separate code for lhs >= -2 and lhs < -2; conversion from double to int truncates, so test2 (-3) == 0.