This is the mail archive of the 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: 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.

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