Re: Division by INT64_MIN

2015-10-08 Thread Matthew Fernandez
On 09/10/15 02:08, Joseph Myers wrote: On Thu, 8 Oct 2015, Matthew Fernandez wrote: On 06/10/15 01:09, Joseph Myers wrote: On Mon, 5 Oct 2015, Matthew Fernandez wrote: on x86 is emitted as a call to __divdi3. If the numerator or denominator are negative, __divdi3 negates them. If either of t

Re: Division by INT64_MIN

2015-10-08 Thread Joseph Myers
On Thu, 8 Oct 2015, Matthew Fernandez wrote: > On 06/10/15 01:09, Joseph Myers wrote: > > On Mon, 5 Oct 2015, Matthew Fernandez wrote: > > > > > on x86 is emitted as a call to __divdi3. If the numerator or denominator > > > are > > > negative, __divdi3 negates them. If either of these values is I

Re: Division by INT64_MIN

2015-10-07 Thread Matthew Fernandez
On 06/10/15 01:09, Joseph Myers wrote: On Mon, 5 Oct 2015, Matthew Fernandez wrote: on x86 is emitted as a call to __divdi3. If the numerator or denominator are negative, __divdi3 negates them. If either of these values is INT64_MIN, I believe this negation is undefined. Is this correct? If thi

Re: Division by INT64_MIN

2015-10-05 Thread Joseph Myers
On Mon, 5 Oct 2015, Matthew Fernandez wrote: > tl;dr: Is dividing by INT64_MIN in C undefined behaviour? No, only dividing by 0 or dividing the minimum value of the type by -1 (and the latter should be defined for -fwrapv, see bug 30484). > on x86 is emitted as a call to __divdi3. If the numera

Division by INT64_MIN

2015-10-04 Thread Matthew Fernandez
Hello all, Apologies in advance if this question is naïve or misdirected. tl;dr: Is dividing by INT64_MIN in C undefined behaviour? In more detail... AIUI when the current target does not have native instructions for a given division or modulo operation, GCC emits calls to software emulation p