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]

RFC: Wextra digest (fixing PR7651)


The goal is to fix PR7651 and convert Wextra into a super-option, that
is an -W* option that just enables other options but it doesn't emit
warnings by itself (other super-options are Wall and Wunused).

This is a summary of the current status of Wextra for mainline to the
best of my knowledge. I welcome comments on how to group and name the
new -W* options that will take over the warnings produced by Wextra.

In Java, Wextra warns for unreachable bytecode.
(maybe this should be warned by -Wunreachable-code or by a new option
-Wunreachable-bytecode)


In C++, it warns for


* Subscripting an array which has been declared register.

* Taking the address of a variable which has been declared register.

* A base class is not initialized in a derived class' copy constructor.

* A non-static reference or non-static const member appears in a class
without constructors.

* Ambiguous virtual bases (virtual base inaccessible due to
ambiguity). (There is also an unconditional warning for direct base
inaccessible due to ambiguity)

* An enumerator and a non-enumerator both appear in a conditional
expression. (There is also an unconditional warning for two different
enumeral types used in a conditional expression).


Only for C, it enables:


* -Wmissing-parameter-type : A function parameter is declared without
a type specifier in K&R-style functions.

* -Wold-style-declaration : Storage-class specifiers like static are
not the first things in a declaration.


For both C and C++:


* A function can return either with or without a value.

* An expression-statement or the left-hand side of a comma expression
contains no side effects. For example, an expression such as x[i,j].
This is also warned by Wunused-value. In addition, Wextra enables
Wunused-value but this is not documented (and -Wunused-value is
already enabled by -Wall).

* If -Wunused or -Wall is given, it enables -Wunused-parameter.
(manual could be more explicit here)

* -Wuninitialized is enabled if -Ox is given. (not documented)

* A pointer is compared against integer zero with <, <=, >, or >=.
This is a pedwarn and it can also be enabled by using -pedantic. If
the pointer is the rightmost operator, there is no warning for Wextra
(surely a bug).

* -Wclobbered : A variable might be changed by longjmp or vfork.

* -Wempty-body : An empty body occurs in an if or else statement.

* -Wsign-compare : A comparison between signed and unsigned values
could produce an incorrect result when the signed value is converted
to unsigned.

* -Wmissing-field-initializers : An aggregate has an initializer which
does not initialize all members.

* -Woverride-init : An initialized field without side effects is
overridden when using
designated initializers.

* An unsigned value is compared against zero with < or >=.
Walways-true claims to warn for this but it doesn't. There is also an
unconditional warning for expressions that are always true or false
due to the range of types.


In ./gcc/config/sh/symbian.c:158 there is a warning enabled by Wextra with the following code (notice the OPT_Wattributes) :

 /* We ignore the dllimport attribute for inline member functions.
    This differs from MSVC behavior which treats it like GNUC
    'extern inline' extension.   */
 else if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INLINE (decl))
   {
     if (extra_warnings)
	warning (OPT_Wattributes, "inline function %q+D is declared as "
		 "dllimport: attribute ignored",
		 decl);
     return false;
   }


Finally, the manual page claims that Wextra warns for any of several floating-point events that often indicate errors, such as overflow, underflow, loss of precision, etc. I wasn't able to find any instance of this. I am fairly sure that Wextra doesn't do such thing.


Cheers,


Manuel.


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