This is the mail archive of the
mailing list for the GCC project.
Re: Criteria for a warning to be in -Wall? (was: Re: a warning to implement)
- From: dewar at gnat dot com (Robert Dewar)
- To: gcc at gcc dot gnu dot org, robertlipe at usa dot net
- Date: Wed, 6 Feb 2002 19:47:28 -0500 (EST)
- Subject: Re: Criteria for a warning to be in -Wall? (was: Re: a warning to implement)
<<This is a useful point....For C++. While I didn't state the source
language in question, it was C89 an this syntax is not valid.
I would say that if you want to write portable code that must be free of
warnings then you are going to have to compromise and occasionally do
a junk initialization. It's hard to believe that this is really
significant (we have a few cases like that in GNAT, and yes, it'
s a bit annoying, but in truth it makes a completely undetectable
difference to performance).
Certainly I would NOT go for using undefined non-portable constructs
(by definition anything undefined is non-portable, since you can't count
on the behavior). In any one of those compilers, one of two reasonable
things can happen:
a. someone reasonably decides that int a = a; should generate a warning.
It looks like GCC may in fact make this decision, but to base the integrity
of your code on NO ONE making this decision across multiple compilers is
unreasonable and a bad idea.
b. someone does something to a compiler that cases int a = a; to have
evil effects. No one seems to be contemplating doing anything to gcc
that might have this effect, though in practice complex optimizers often
do surprising things that are not obvious. However, again counting on
NO compiler to do this is again asking for trouble.
I actually find the requirement to write portable code that compiles with
no warnings on multiple compilers itself to be seriously flawed. You can
never tell when one of the compilers in question will add a new warning
that just happens to hit your code.