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: Inconsistent error/pedwarn: ISO C++


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


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