This is the mail archive of the
`gcc@gcc.gnu.org`
mailing list for the GCC project.

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |

Other format: | [Raw text] |

*From*: Gabriel Dos Reis <gdr at cs dot tamu dot edu>*To*: gcc at gcc dot gnu dot org*Date*: 16 Jan 2007 12:05:12 -0600*Subject*: Re: Miscompilation of remainder expressions*References*: <45AB8770.5040402@cs.unipr.it> <17835.35470.712620.903057@zebedee.pink> <45ACF183.4020406@cs.unipr.it> <17836.62513.471923.766318@zebedee.pink>

Andrew Haley <aph@redhat.com> writes: | Roberto Bagnara writes: | > Andrew Haley wrote: | > > Roberto Bagnara writes: | > > > | > > > 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 (which, to me, looks quite serious)? | > > | > > No, there aren't. It would make more sense for you to wrap % in some | > > code that checks for this, rather than for us to slow down every division | > > for this one special case. | > | > With all due respect, I must say I am shocked. I always thought | > (and taught) that we, Free Software people, value standard conformance | > and getting things right. | | This is a disgreement about interpretation of the langauge in the | standard, which is: | | "The result of the / operator is the quotient from the division of the | first operand by the second; the result of the % operator is the | remainder. In both operations, if the value of the second operand is | zero, the behavior is undefined. When integers are divided, the result | of the / operator is the algebraic quotient with any fractional part | discarded.87) If the quotient a/b is representable, the expression | (a/b)*b + a%b shall equal a." | | If the quotient a/b is *not* representable, is the behaviour of % | well-defined or not? It doesn't say. Andrew and me exchanged (private) viewpoints of this yesterday. I would like to add something I forgot to say. By definition, the absolute value of "a % b" is always less than the absolute value of b. Consequently, "a % b" is always defined. -- Gaby

**Follow-Ups**:**Re: Miscompilation of remainder expressions***From:*Joe Buck

**References**:**Miscompilation of remainder expressions***From:*Roberto Bagnara

**Re: Miscompilation of remainder expressions***From:*Andrew Haley

**Re: Miscompilation of remainder expressions***From:*Roberto Bagnara

**Re: Miscompilation of remainder expressions***From:*Andrew Haley

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |