[cfe-commits] r79743 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/compare.c

Eli Friedman eli.friedman at gmail.com
Sat Aug 22 16:42:12 PDT 2009


On Sat, Aug 22, 2009 at 4:36 PM, Chris Lattner<sabre at nondot.org> wrote:
>
> On Aug 22, 2009, at 4:08 PM, Eli Friedman wrote:
>
>> On Sat, Aug 22, 2009 at 11:58 AM, Chris Lattner<sabre at nondot.org> wrote:
>>>
>>> Author: lattner
>>> Date: Sat Aug 22 13:58:31 2009
>>> New Revision: 79743
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=79743&view=rev
>>> Log:
>>> tweak some pointer sema checking stuff (which was added to implement
>>> PR4175) to
>>> avoid emitting a warning on "someptr > 0".  This is obviously
>>> questionable (they
>>> could use != instead) but is reasonable, and the warning "ordered
>>> comparison
>>> between pointer and integer" didn't make a ton of sense because 0 is a
>>> valid
>>> null pointer constant.
>>
>> Sure, but the standard requires us to warn... it would be okay to
>> split it into a separate warning, though.
>
> It does?  Citation?

C99 6.5.8p2:
One of the following shall hold:
-- both operands have real type;
-- both operands are pointers to qualified or unqualified versions of
compatible object types; or
-- both operands are pointers to qualified or unqualified versions of
compatible incomplete types.

None of those hold, so it's a constraint violation.  Note that
equality operators make an explicit allowance for null pointer
constants.

-Eli




More information about the cfe-commits mailing list