This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PR 21438 : Warning about division by zero depends on lexical form
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