This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Inconsistent error/pedwarn: ISO C++
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- Cc: Doug Gregor <doug dot gregor at gmail dot com>, GCC <gcc at gcc dot gnu dot org>
- Date: Sun, 30 Sep 2007 20:48:15 -0700
- Subject: Re: Inconsistent error/pedwarn: ISO C++
- References: <24b520d20709200417s381199c5x6ac1551838f59e48@mail.gmail.com> <6c33472e0709240709t6b68fd2w1b98790188d638ab@mail.gmail.com>
Manuel López-Ibáñez wrote:
> On 20/09/2007, Doug Gregor <doug.gregor@gmail.com> wrote:
>> We can't seem to decide whether ISO C++ really forbids comparisons
>> between pointers and integers or not. The first two are for == and !=,
>> the second two are for <, >, <=, >=. Why the inconsistency?
>>
>> typeck.c: error ("ISO C++ forbids comparison between pointer
>> and integer");
>> typeck.c: error ("ISO C++ forbids comparison between pointer
>> and integer");
>> typeck.c: pedwarn ("ISO C++ forbids comparison between
>> pointer and integer");
>> typeck.c: pedwarn ("ISO C++ forbids comparison between
>> pointer and integer");
These should all be pedwarns.
The basic principle is to use pedwarn for things that have well-defined
GNU semantics, but don't happen to be legal. That's especially true for
things that are valid in GNU C. Here, the well-defined GNU semantics
are that the integer is converted to the pointer type, as if by a cast.
A patch to convert to pedwarns is pre-approved, if accompanied by a
testcase.
Thanks,
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713