[cfe-dev] Possibly invalid enum tautology warning

John McCall rjmccall at apple.com
Sun Aug 7 14:21:24 PDT 2011


On Aug 7, 2011, at 1:32 PM, David Blaikie wrote:
> On Sun, Aug 7, 2011 at 12:29 PM, John McCall <rjmccall at apple.com> wrote:
>> but it sounds
>> like you're arguing that we should suppress warnings when another
>> platform exists where the warning wouldn't trigger.
> 
> In this particular case I think that's what he's saying, yes. But I
> wouldn't say that implies the general statement you've made.

He phrased it pretty generally.  I was shying away from the specifics
of this case because, while the underlying type of an enum is
indeed implementation-specific, the promotion rules actually are
governed by the standard, and therefore the behavior of this
promotion is not really compiler-specific at all.  This would be
clearer if we saw the actual enum definition.

>> it's
>> contrary to what most people writing portable code want;  indeed,
>> we frequently get the dual request, to enable warnings on code that
>> works on the current platform but wouldn't on something else.
> 
> & what's your opinion when such a request is made?

That it's an interesting idea, but extremely false-positive prone, and it
would be expensive to get most of those false positives out.  Very few
people are interested in truly arbitrary portability — I mean, case in
point, our code base consistently assumes that 'unsigned' is at least
32 bits (the host unsigned, not the target unsigned, of course).  That's
not a perfectly portable assumption at all, but it's true of every
platform we will ever care about running on.  There's no good way
to deduce that kind of thing.

Plus, it's not like portability is actually assured just by stamping out
portability-related compiler warnings;  while an automated checker
can catch some obvious things, portability is actually a long tail
of problems, and projects that actually care about portability
should be regularly building and testing on all their supported
platforms anyway.  It's hard to get too excited about adding
extensive portability checking when any sane setup will have a
buildbot which warns about the problem within a couple of hours.

I think a good portability checker might make an interesting
static analysis, though.

John.



More information about the cfe-dev mailing list