[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    Re: PR 21438 : Warning about division by zero depends on lexical  form
From:       Mark Mitchell <mark () codesourcery ! com>
Date:       2007-01-29 22:50:22
Message-ID: 45BE7A2E.9030701 () codesourcery ! com
[Download RAW message or body]

Manuel López-Ibáñez wrote:
> On 29/01/07, Mark Mitchell <mark@codesourcery.com> wrote:
>> > The C++ front-end, on the contrary, warns always. Is this an
>> inconsistency?
>>
>> Yes, I think the two front ends should behave the same in this respect.
>>
> OK but what is the desired behaviour?

Heh. :-)

I'm not sure.  We have __builtin_nan() for generating NaNs, and C99 has
a NAN macro, which, IIUC, should be implemented as a call to
__builtin_nan() in the C library, if designed for use with GCC.  So, one
point of view is that we don't need to special-case 0.0 / 0.0, and that
we should warn about that too.  On the other hand, lots of code
(including code designed for older versions of GCC or other compilers)
may do that as a way of getting a NaN.

In the absence of a clear reason for change, we should preserve existing
behavior, so my feeling is that we shouldn't warn.

I think that the simplest path forward is to (a) factor the check into a
separate function, (b) apply your patch (which makes the warning
behavior not depend so closely on exactly how the division is
presented), and then (c) make the C++ front end use the new function.
That will make the C++ front end warning behavior the same as C.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic