https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107174
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There is no bug here as signed integer overflow is undefined. You should do the following if you want unsigned conversion. __attribute__((noinline)) double deltaToDouble(int a, int b) { unsigned ua = a; unsigned ub = b; if (a < b) { unsigned int delta = ub - ua; return -((double)delta); } else { unsigned int delta = ua - ub; return (double)delta; } } Otherwise GCC will assume (a - b) and (b - a) will never be overflow (as it is undefined) and you will get the signed coversions.