https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108365
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- With r9-1730 or later, I think the problem is that something decides to narrow the division from long long to int. In long long it is well defined if b is non-zero as -2147483648LL / -1LL is 2147483648LL. But when we instead narrow it to -2147483648 / -1 is UB which triggers division by zero exception. We don't seem to narrow: int foo (int x, int y) { return (long long) x / (long long) y; } so probably we do it only if the dividend is constant or something similar; if yes, then the fix would be stop narrowing if the dividend is the minimum of the narrower type.