Re: Miscompilation of remainder expressions

2007-01-15 Thread Roberto Bagnara
Andrew Haley wrote: Paolo Carlini writes: I would like to understand the issue better, however... What more is there to understand? It's an integer overflow. The processor generates a trap on integer overflows during division operations. Just because the wrong code is generated for

Re: Miscompilation of remainder expressions

2007-01-15 Thread Paolo Carlini
Andrew Haley wrote: Paolo Carlini writes: I would like to understand the issue better, however... What more is there to understand? It's an integer overflow. The processor generates a trap on integer overflows during division operations. Yes, sorry, now I see that in the specific case

Re: Miscompilation of remainder expressions

2007-01-15 Thread Roberto Bagnara
Paolo Carlini wrote: Andrew Haley wrote: Paolo Carlini writes: I would like to understand the issue better, however... What more is there to understand? It's an integer overflow. The processor generates a trap on integer overflows during division operations. Yes, sorry, now I see that

Re: Miscompilation of remainder expressions

2007-01-15 Thread Paolo Carlini
Roberto Bagnara wrote: No, Paolo: the result of INT_MIN % -1 is zero, according to the standard. There is no overflow whatsoever involved. The overflow that you see is simply an artifact of GCC that produces assembly code that does not implement remainder expressions correctly. Ok, I

Re: Miscompilation of remainder expressions

2007-01-15 Thread Andrew Haley
Paolo Carlini writes: Roberto Bagnara wrote: No, Paolo: the result of INT_MIN % -1 is zero, according to the standard. There is no overflow whatsoever involved. The overflow that you see is simply an artifact of GCC that produces assembly code that does not implement remainder

Re: Miscompilation of remainder expressions

2007-01-15 Thread Paolo Carlini
Andrew Haley wrote: Ok, I believe you. However, isn't true that, in general, because the sign of the result is implementation defined, The sign of the result of % is no longer (since C99) implementation- defined. I see. However, by default, I'm always talking about C++03... Paolo.

Re: Miscompilation of remainder expressions

2007-01-15 Thread Andrew Haley
Paolo Carlini writes: Andrew Haley wrote: Ok, I believe you. However, isn't true that, in general, because the sign of the result is implementation defined, The sign of the result of % is no longer (since C99) implementation- defined. I see. However, by default, I'm

Re: Miscompilation of remainder expressions

2007-01-15 Thread Gabriel Dos Reis
Andrew Haley [EMAIL PROTECTED] writes: | Paolo Carlini writes: | Andrew Haley wrote: | | Ok, I believe you. However, isn't true that, in general, because the | sign of the result is implementation defined, | | The sign of the result of % is no longer (since C99) implementation-

Re: Miscompilation of remainder expressions

2007-01-15 Thread Gabriel Dos Reis
Andrew Haley [EMAIL PROTECTED] writes: | Paolo Carlini writes: | Andrew Haley wrote: | | Ok, I believe you. However, isn't true that, in general, because the | sign of the result is implementation defined, | | The sign of the result of % is no longer (since C99) implementation-

Re: Miscompilation of remainder expressions

2007-01-15 Thread Michael Veksler
Roberto Bagnara wrote: Reading the thread Autoconf manual's coverage of signed integer overflow portability I was horrified to discover about GCC's miscompilation of the remainder expression that causes INT_MIN % -1 to cause a SIGFPE on CPUs of the i386 family. Are there plans to fix this bug

Re: Miscompilation of remainder expressions

2007-01-15 Thread Gabriel Paubert
On Mon, Jan 15, 2007 at 10:34:23PM +0200, Michael Veksler wrote: Roberto Bagnara wrote: Reading the thread Autoconf manual's coverage of signed integer overflow portability I was horrified to discover about GCC's miscompilation of the remainder expression that causes INT_MIN % -1 to cause

<    1   2