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]
Other format: [Raw text]

Re: RFC: -Wall by default


On 4/8/2012 4:02 PM, Jonathan Wakely wrote:
No, because those are already in bugzilla, and there's a whole wiki
page about improving that particular warning.

Yes, I know, and that page is to me good justification for NOT including this warning in the set that is on by default.

But I'd be just as happy with a -Wstandard (by any name) enabled by default as I would be with -Wall on by default. Only enabling warnings with very little chance of false positives would avoid most of the negative consequences.

Yes, I think that is the case! That's certainly the philosophy we follow in GNAT.

One debatable issue is the following kind of warnings:

     1. procedure k is
     2.    x : integer;
           |
        >>> warning: variable "x" is assigned but never read

     3. begin
     4.    x := 2;
           |
        >>> warning: useless assignment to "x", value never referenced

5. end;

These (not on by default in GNAT by the way) are examples of warnings that most certainly are NOT false positives, but they are examples of warnings about perfectly valid code.

That's quite different from a warning like:

     1. function l (m : integer) return Boolean is
     2. begin
     3.    if m > 10 then
           |
        >>> warning: "return" statement missing following this statement
        >>> warning: Program_Error may be raised at run time

     4.       return False;
     5.    end if;
     6. end;

Where you definitely have a real bug in the code, and the code is not in any reasonable sense valid (yes, the RM does not make this code illegal, but that's just because it would be too much effort).

An interesting third category is:

     1. procedure Norm is
     2. begin
     3.    pragma Dummy_Body;
                  |
        >>> warning: unrecognized pragma "Dummy_Body"

     4.    null;
     5. end;

Here the standard mandates ignoring unrecognized pragmas, so the compiler is doing the right thing, and in one sense the above is a false positive, since there is nothing wrong. However, in this case we have the following (highly peculiar) statement in the RM

13  The implementation shall give a warning message for an unrecognized pragma
name.

(why highly peculiar, becuase in a formal definition of this kind the notion of "warning message" is totally undefined and pretty much undefinable.)


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