This is the mail archive of the gcc@gcc.gnu.org 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]

Re: Warnings in the C++ Front-End and GCC in General


On Tue, 8 Sep 1998, Joe Buck wrote:

> > What if you worked for a company that required, as part of their coding
> > style, warningless compilation?
> But if we provide pragmas to turn off warnings and you use them, you
> are violating your company's coding style!

Not at all. The warning is not generated despite the strict compilation
options, so I reach the goal: some nigtly running cron job that compiles
the whole project and scans the output for diagnostics won't find any.

> (This is why -Wall should only contain warnings that can be silenced
> without making code worse).

Clearly, this is not the case. Initializing a variable does make the code
worse, and so does providing an unreachable "return 0;" statement. 
Granted, it's a minor difference, but it exists. More importantly, such
code makes other people looking at the code wonder "Hmm, this is a dead
code, maybe there's a bug somewhere here?". Sure, I can (and actually do)
put comments like "to shut -Wall up", but that's just an awful patch on
top of another patch.

> > Personally, I hate it when I have to provide bogus initialisation for auto
> > variables or provide unreachable return statements just because the
> > compiler is not smart enough. I understand that it's unreasonable to
> > expect it to be so smart, but still I hate being forced to cheat it.
> In such cases, rather than turning off warnings, a mechanism like the
> old lint /*NOTREACHED*/ would be preferable.

What would be preferable in it, compared to pragmas or whatever else?

/ Kamil Iskra    AmigaOS  Linux/i386  Linux/m68k               \
| GeekGadgets GCC maintainer   UNIX system administrator       |
| iskra@student.uci.agh.edu.pl  kiskra@ernie.icslab.agh.edu.pl |
\ kamil@dwd.interkom.pl   http://student.uci.agh.edu.pl/~iskra /



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