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]

RE: Miscompilation of remainder expressions


On 16 January 2007 18:42, Robert Dewar wrote:

> Dave Korn wrote:
>> On 16 January 2007 18:23, Robert Dewar wrote:
>> 
>>> Gabriel Paubert wrote:
>>> \
>>>> No, because the instruction has actually two result values:
>>>> 
>>>> - the remainder, which you could safely set to zero (not 1!)
>>>> 
>>>> - the quotient, which is affected by the overflow and there may be
>>>>   compiler and languages that rely on the exception being generated.
>>> But the division is undefined, programs have no right to
>>> rely on an exception being generated.
>> 
>>   It really depends whether you think of the % operator as being an atomic
>> mathematical operation, or a compound function involving real division and
>> multiplication and subtraction.  I think the wording of the standard says
>> only that the inequality "(a/b)*b + a%b == a" does not hold when (a/b)
>> cannot be represented, but does not deny the modulo operator the option of
>> just returning the correct result, which is representable.
> 
> I think you missed my point

  Oops, yeh.  I was thinking of Andrew Haley's question about the wording of
the language in the standard.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]