[cfe-dev] Possibly invalid enum tautology warning

David Blaikie dblaikie at gmail.com
Mon Aug 8 13:18:13 PDT 2011


On Mon, Aug 8, 2011 at 1:08 PM, Peter Geoghegan <peter at 2ndquadrant.com> wrote:
> On 8 August 2011 20:59, David Blaikie <dblaikie at gmail.com> wrote:
>> If there's some other case where testing "enum_value > 0" could be
>> justified, then perhaps we could talk about that - but without a use
>> case it doesn't seem worth addressing on such theoretical grounds.
>
> Notably, Clang fairly arbitrarily doesn't show the warning when the
> enum constant is used in place of a 0 rvalue. Why?

As per John's reply earlier/yesterday:

" When I
was implementing it, I was persuaded that we ought to have a
special case for comparing against an enumerator which happens
to be zero, because that was indicative of a particular common
and harmless idiom (specifically, things like if (v < v_first || v > v_last))."



More information about the cfe-dev mailing list