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

Mark Mitchell mark@markmitchell.com
Wed Sep 9 05:52:00 GMT 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!
> 

That seems a little too simplistic.  Suppose, more reasonably, that you
were required to examine all warnings, perhaps with peer review, and
then either modify the code (if it did not meet company requirements),
or (if it did meet company requirements) hush the warning so that in 
the future people would not be distracted by the warning?

Of course, if your compiler cannot hush warnings, you can't meet the
second part of the standard, but that's not the point I'm trying to 
make.  The point is that, with GCC, you would just have to accept
the warning, even after verifying your code, and continue to look at the
warning over and over again forevermore.

To preempt a natural counter-argument, let me say that yes, there is a
risk that code that was once verified will become incorrect for
some reason, that the warning will not be issued do the local
disablement of warnings, and that all heck will break loose.  That's
why, as with all features (including, say, -Wno-sign-compare), one 
must use this one judiciously. 

You suggest lint-like comments as a way of hushing some warnings. 
That's fine; I have no strong preference for #pramgas, _Pragmas,
lint-like comments, or other mechanisms.  All I suggest is that 
whatever mechanism selected be general enough to handle all warnings;
not just those for which there is existing lint-like comment syntax.

-- Mark



More information about the Gcc mailing list