This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Miscompilation of remainder expressions
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: "'Robert Dewar'" <dewar at adacore dot com>
- Cc: "'Gabriel Paubert'" <paubert at iram dot es>, "'Michael Veksler'" <mveksler at techunix dot technion dot ac dot il>, <gcc at gcc dot gnu dot org>
- Date: Tue, 16 Jan 2007 18:46:16 -0000
- Subject: 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....