Warnings in the C++ Front-End and GCC in General
Kamil Iskra
kamil@dwd.interkom.pl
Wed Sep 9 06:51:00 GMT 1998
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 /
More information about the Gcc
mailing list