reached, for example because an error is found during compilation, or because the \fB\-fsyntax\-only\fR option is being used. .IP "\fB\-Wstrict\-selector\-match\fR (Objective-C and Objective\-\*(C+ only)" 4 .IX Item "-Wstrict-selector-match (Objective-C and Objective- only)" Warn if multiple methods with differing argument and/or return types are found for a given selector when attempting to send a message using this selector to a receiver of type \f(CW\*(C`id\*(C'\fR or \f(CW\*(C`Class\*(C'\fR. When this flag is off (which is the default behavior), the compiler will omit such warnings if any differences found are confined to types which share the same size and alignment. .IP "\fB\-Wundeclared\-selector\fR (Objective-C and Objective\-\*(C+ only)" 4 .IX Item "-Wundeclared-selector (Objective-C and Objective- only)" Warn if a \f(CW\*(C`@selector(...)\*(C'\fR expression referring to an undeclared selector is found. A selector is considered undeclared if no method with that name has been declared before the \&\f(CW\*(C`@selector(...)\*(C'\fR expression, either explicitly in an \&\f(CW@interface\fR or \f(CW@protocol\fR declaration, or implicitly in an \f(CW@implementation\fR section. This option always performs its checks as soon as a \f(CW\*(C`@selector(...)\*(C'\fR expression is found, while \fB\-Wselector\fR only performs its checks in the final stage of compilation. This also enforces the coding style convention that methods and selectors must be declared before being used. .IP "\fB\-print\-objc\-runtime\-info\fR" 4 .IX Item "-print-objc-runtime-info" Generate C header describing the largest structure that is passed by value, if any. .Sh "Options to Control Diagnostic Messages Formatting" .IX Subsection "Options to Control Diagnostic Messages Formatting" Traditionally, diagnostic messages have been formatted irrespective of the output device's aspect (e.g. its width, ...). The options described below can be used to control the diagnostic messages formatting algorithm, e.g. how many characters per line, how often source location information should be reported. Right now, only the \*(C+ front end can honor these options. However it is expected, in the near future, that the remaining front ends would be able to digest them correctly. .IP "\fB\-fmessage\-length=\fR\fIn\fR" 4 .IX Item "-fmessage-length=n" Try to format error messages so that they fit on lines of about \fIn\fR characters. The default is 72 characters for \fBg++\fR and 0 for the rest of the front ends supported by \s-1GCC\s0. If \fIn\fR is zero, then no line-wrapping will be done; each error message will appear on a single line. .IP "\fB\-fdiagnostics\-show\-location=once\fR" 4 .IX Item "-fdiagnostics-show-location=once" Only meaningful in line-wrapping mode. Instructs the diagnostic messages reporter to emit \fIonce\fR source location information; that is, in case the message is too long to fit on a single physical line and has to be wrapped, the source location won't be emitted (as prefix) again, over and over, in subsequent continuation lines. This is the default behavior. .IP "\fB\-fdiagnostics\-show\-location=every\-line\fR" 4 .IX Item "-fdiagnostics-show-location=every-line" Only meaningful in line-wrapping mode. Instructs the diagnostic messages reporter to emit the same source location information (as prefix) for physical lines that result from the process of breaking a message which is too long to fit on a single line. .IP "\fB\-fdiagnostics\-show\-option\fR" 4 .IX Item "-fdiagnostics-show-option" This option instructs the diagnostic machinery to add text to each diagnostic emitted, which indicates which command line option directly controls that diagnostic, when such an option is known to the diagnostic machinery. .IP "\fB\-Wcoverage\-mismatch\fR" 4 .IX Item "-Wcoverage-mismatch" Warn if feedback profiles do not match when using the \&\fB\-fprofile\-use\fR option. If a source file was changed between \fB\-fprofile\-gen\fR and \&\fB\-fprofile\-use\fR, the files with the profile feedback can fail to match the source file and \s-1GCC\s0 can not use the profile feedback information. By default, \s-1GCC\s0 emits an error message in this case. The option \fB\-Wcoverage\-mismatch\fR emits a warning instead of an error. \s-1GCC\s0 does not use appropriate feedback profiles, so using this option can result in poorly optimized code. This option is useful only in the case of very minor changes such as bug fixes to an existing code-base. .Sh "Options to Request or Suppress Warnings" .IX Subsection "Options to Request or Suppress Warnings" Warnings are diagnostic messages that report constructions which are not inherently erroneous but which are risky or suggest there may have been an error. .PP The following language-independent options do not enable specific warnings but control the kinds of diagnostics produced by \s-1GCC\s0. .IP "\fB\-fsyntax\-only\fR" 4 .IX Item "-fsyntax-only" Check the code for syntax errors, but don't do anything beyond that. .IP "\fB\-w\fR" 4 .IX Item "-w" Inhibit all warning messages. .IP "\fB\-Werror\fR" 4 .IX Item "-Werror" Make all warnings into errors. .IP "\fB\-Werror=\fR" 4 .IX Item "-Werror=" Make the specified warning into an error. The specifier for a warning is appended, for example \fB\-Werror=switch\fR turns the warnings controlled by \fB\-Wswitch\fR into errors. This switch takes a negative form, to be used to negate \fB\-Werror\fR for specific warnings, for example \fB\-Wno\-error=switch\fR makes \&\fB\-Wswitch\fR warnings not be errors, even when \fB\-Werror\fR is in effect. You can use the \fB\-fdiagnostics\-show\-option\fR option to have each controllable warning amended with the option which controls it, to determine what to use with this option. .Sp Note that specifying \fB\-Werror=\fR\fIfoo\fR automatically implies \&\fB\-W\fR\fIfoo\fR. However, \fB\-Wno\-error=\fR\fIfoo\fR does not imply anything. .IP "\fB\-Wfatal\-errors\fR" 4 .IX Item "-Wfatal-errors" This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printing further error messages. .PP You can request many specific warnings with options beginning \&\fB\-W\fR, for example \fB\-Wimplicit\fR to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning \fB\-Wno\-\fR to turn off warnings; for example, \fB\-Wno\-implicit\fR. This manual lists only one of the two forms, whichever is not the default. For further, language-specific options also refer to \fB\*(C+ Dialect Options\fR and \&\fBObjective-C and Objective\-\*(C+ Dialect Options\fR. .IP "\fB\-pedantic\fR" 4 .IX Item "-pedantic" Issue all the warnings demanded by strict \s-1ISO\s0 C and \s-1ISO\s0 \*(C+; reject all programs that use forbidden extensions, and some other programs that do not follow \s-1ISO\s0 C and \s-1ISO\s0 \*(C+. For \s-1ISO\s0 C, follows the version of the \s-1ISO\s0 C standard specified by any \fB\-std\fR option used. .Sp Valid \s-1ISO\s0 C and \s-1ISO\s0 \*(C+ programs should compile properly with or without this option (though a rare few will require \fB\-ansi\fR or a \&\fB\-std\fR option specifying the required version of \s-1ISO\s0 C). However, without this option, certain \s-1GNU\s0 extensions and traditional C and \*(C+ features are supported as well. With this option, they are rejected. .Sp \&\fB\-pedantic\fR does not cause warning messages for use of the alternate keywords whose names begin and end with \fB_\|_\fR. Pedantic warnings are also disabled in the expression that follows \&\f(CW\*(C`_\|_extension_\|_\*(C'\fR. However, only system header files should use these escape routes; application programs should avoid them. .Sp Some users try to use \fB\-pedantic\fR to check programs for strict \s-1ISO\s0 C conformance. They soon find that it does not do quite what they want: it finds some non-ISO practices, but not all\-\-\-only those for which \&\s-1ISO\s0 C \fIrequires\fR a diagnostic, and some others for which diagnostics have been added. .Sp A feature to report any failure to conform to \s-1ISO\s0 C might be useful in some instances, but would require considerable additional work and would be quite different from \fB\-pedantic\fR. We don't have plans to support such a feature in the near future. .Sp Where the standard specified with \fB\-std\fR represents a \s-1GNU\s0 extended dialect of C, such as \fBgnu89\fR or \fBgnu99\fR, there is a corresponding \fIbase standard\fR, the version of \s-1ISO\s0 C on which the \s-1GNU\s0 extended dialect is based. Warnings from \fB\-pedantic\fR are given where they are required by the base standard. (It would not make sense for such warnings to be given only for features not in the specified \s-1GNU\s0 C dialect, since by definition the \s-1GNU\s0 dialects of C include all features the compiler supports with the given option, and there would be nothing to warn about.) .IP "\fB\-pedantic\-errors\fR" 4 .IX Item "-pedantic-errors" Like \fB\-pedantic\fR, except that errors are produced rather than warnings. .IP "\fB\-Wall\fR" 4 .IX Item "-Wall" This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in conjunction with macros. This also enables some language-specific warnings described in \fB\*(C+ Dialect Options\fR and \fBObjective-C and Objective\-\*(C+ Dialect Options\fR. .Sp \&\fB\-Wall\fR turns on the following warning flags: .Sp \&\fB\-Waddress \&\-Warray\-bounds\fR (only with\fB \fR\fB\-O2\fR) \&\fB\-Wc++0x\-compat \&\-Wchar\-subscripts \&\-Wimplicit\-int \&\-Wimplicit\-function\-declaration \&\-Wcomment \&\-Wformat \&\-Wmain\fR (only for C/ObjC and unless\fB \fR\fB\-ffreestanding\fR) \&\fB\-Wmissing\-braces \&\-Wnonnull \&\-Wparentheses \&\-Wpointer\-sign \&\-Wreorder \&\-Wreturn\-type \&\-Wsequence\-point \&\-Wsign\-compare\fR (only in \*(C+) \&\fB\-Wstrict\-aliasing \&\-Wstrict\-overflow=1 \&\-Wswitch \&\-Wtrigraphs \&\-Wuninitialized\fR (only with\fB \fR\fB\-O1\fR\fB \fRand above) \&\fB\-Wunknown\-pragmas \&\-Wunused\-function \&\-Wunused\-label \&\-Wunused\-value \&\-Wunused\-variable\fR .Sp Note that some warning flags are not implied by \fB\-Wall\fR. Some of them warn about constructions that users generally do not consider questionable, but which occasionally you might wish to check for; others warn about constructions that are necessary or hard to avoid in some cases, and there is no simple way to modify the code to suppress the warning. Some of them are enabled by \fB\-Wextra\fR but many of them must be enabled individually. .IP "\fB\-Wextra\fR" 4 .IX Item "-Wextra" This enables some extra warning flags that are not enabled by \&\fB\-Wall\fR. (This option used to be called \fB\-W\fR. The older name is still supported, but the newer name is more descriptive.) .Sp \&\fB\-Wclobbered \&\-Wempty\-body \&\-Wignored\-qualifiers \&\-Wmissing\-field\-initializers \&\-Wmissing\-parameter\-type\fR (C only) \&\fB\-Wold\-style\-declaration\fR (C only) \&\fB\-Woverride\-init \&\-Wsign\-compare \&\-Wtype\-limits \&\-Wuninitialized\fR (only with\fB \fR\fB\-O1\fR\fB \fRand above) \&\fB\-Wunused\-parameter\fR (only with\fB \fR\fB\-Wunused\fR\fB \fRor\fB \fR\fB\-Wall\fR) \fB \fR .Sp The option \fB\-Wextra\fR also prints warning messages for the following cases: .RS 4 .IP "\(bu" 4 A pointer is compared against integer zero with \fB<\fR, \fB<=\fR, \&\fB>\fR, or \fB>=\fR. .IP "\(bu" 4 (\*(C+ only) An enumerator and a non-enumerator both appear in a conditional expression. .IP "\(bu" 4 (\*(C+ only) A non-static reference or non-static \fBconst\fR member appears in a class without constructors. .IP "\(bu" 4 (\*(C+ only) Ambiguous virtual bases. .IP "\(bu" 4 (\*(C+ only) Subscripting an array which has been declared \fBregister\fR. .IP "\(bu" 4 (\*(C+ only) Taking the address of a variable which has been declared \&\fBregister\fR. .IP "\(bu" 4 (\*(C+ only) A base class is not initialized in a derived class' copy constructor. .RE .RS 4 .RE .IP "\fB\-Wno\-import\fR" 4 .IX Item "-Wno-import" Inhibit warning messages about the use of \fB#import\fR. .IP "\fB\-Wchar\-subscripts\fR" 4 .IX Item "-Wchar-subscripts" Warn if an array subscript has type \f(CW\*(C`char\*(C'\fR. This is a common cause of error, as programmers often forget that this type is signed on some machines. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wcomment\fR" 4 .IX Item "-Wcomment" Warn whenever a comment-start sequence \fB/*\fR appears in a \fB/*\fR comment, or whenever a Backslash-Newline appears in a \fB//\fR comment. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wformat\fR" 4 .IX Item "-Wformat" Check calls to \f(CW\*(C`printf\*(C'\fR and \f(CW\*(C`scanf\*(C'\fR, etc., to make sure that the arguments supplied have types appropriate to the format string specified, and that the conversions specified in the format string make sense. This includes standard functions, and others specified by format attributes, in the \f(CW\*(C`printf\*(C'\fR, \&\f(CW\*(C`scanf\*(C'\fR, \f(CW\*(C`strftime\*(C'\fR and \f(CW\*(C`strfmon\*(C'\fR (an X/Open extension, not in the C standard) families (or other target-specific families). Which functions are checked without format attributes having been specified depends on the standard version selected, and such checks of functions without the attribute specified are disabled by \&\fB\-ffreestanding\fR or \fB\-fno\-builtin\fR. .Sp The formats are checked against the format features supported by \s-1GNU\s0 libc version 2.2. These include all \s-1ISO\s0 C90 and C99 features, as well as features from the Single Unix Specification and some \s-1BSD\s0 and \s-1GNU\s0 extensions. Other library implementations may not support all these features; \s-1GCC\s0 does not support warning about features that go beyond a particular library's limitations. However, if \fB\-pedantic\fR is used with \fB\-Wformat\fR, warnings will be given about format features not in the selected standard version (but not for \f(CW\*(C`strfmon\*(C'\fR formats, since those are not in any version of the C standard). .Sp Since \fB\-Wformat\fR also checks for null format arguments for several functions, \fB\-Wformat\fR also implies \fB\-Wnonnull\fR. .Sp \&\fB\-Wformat\fR is included in \fB\-Wall\fR. For more control over some aspects of format checking, the options \fB\-Wformat\-y2k\fR, \&\fB\-Wno\-format\-extra\-args\fR, \fB\-Wno\-format\-zero\-length\fR, \&\fB\-Wformat\-nonliteral\fR, \fB\-Wformat\-security\fR, and \&\fB\-Wformat=2\fR are available, but are not included in \fB\-Wall\fR. .IP "\fB\-Wformat\-y2k\fR" 4 .IX Item "-Wformat-y2k" If \fB\-Wformat\fR is specified, also warn about \f(CW\*(C`strftime\*(C'\fR formats which may yield only a two-digit year. .IP "\fB\-Wno\-format\-extra\-args\fR" 4 .IX Item "-Wno-format-extra-args" If \fB\-Wformat\fR is specified, do not warn about excess arguments to a \&\f(CW\*(C`printf\*(C'\fR or \f(CW\*(C`scanf\*(C'\fR format function. The C standard specifies that such arguments are ignored. .Sp Where the unused arguments lie between used arguments that are specified with \fB$\fR operand number specifications, normally warnings are still given, since the implementation could not know what type to pass to \f(CW\*(C`va_arg\*(C'\fR to skip the unused arguments. However, in the case of \f(CW\*(C`scanf\*(C'\fR formats, this option will suppress the warning if the unused arguments are all pointers, since the Single Unix Specification says that such unused arguments are allowed. .IP "\fB\-Wno\-format\-zero\-length\fR (C and Objective-C only)" 4 .IX Item "-Wno-format-zero-length (C and Objective-C only)" If \fB\-Wformat\fR is specified, do not warn about zero-length formats. The C standard specifies that zero-length formats are allowed. .IP "\fB\-Wformat\-nonliteral\fR" 4 .IX Item "-Wformat-nonliteral" If \fB\-Wformat\fR is specified, also warn if the format string is not a string literal and so cannot be checked, unless the format function takes its format arguments as a \f(CW\*(C`va_list\*(C'\fR. .IP "\fB\-Wformat\-security\fR" 4 .IX Item "-Wformat-security" If \fB\-Wformat\fR is specified, also warn about uses of format functions that represent possible security problems. At present, this warns about calls to \f(CW\*(C`printf\*(C'\fR and \f(CW\*(C`scanf\*(C'\fR functions where the format string is not a string literal and there are no format arguments, as in \f(CW\*(C`printf (foo);\*(C'\fR. This may be a security hole if the format string came from untrusted input and contains \fB\f(CB%n\fB\fR. (This is currently a subset of what \fB\-Wformat\-nonliteral\fR warns about, but in future warnings may be added to \fB\-Wformat\-security\fR that are not included in \fB\-Wformat\-nonliteral\fR.) .IP "\fB\-Wformat=2\fR" 4 .IX Item "-Wformat=2" Enable \fB\-Wformat\fR plus format checks not included in \&\fB\-Wformat\fR. Currently equivalent to \fB\-Wformat \&\-Wformat\-nonliteral \-Wformat\-security \-Wformat\-y2k\fR. .IP "\fB\-Wnonnull\fR (C and Objective-C only)" 4 .IX Item "-Wnonnull (C and Objective-C only)" Warn about passing a null pointer for arguments marked as requiring a non-null value by the \f(CW\*(C`nonnull\*(C'\fR function attribute. .Sp \&\fB\-Wnonnull\fR is included in \fB\-Wall\fR and \fB\-Wformat\fR. It can be disabled with the \fB\-Wno\-nonnull\fR option. .IP "\fB\-Winit\-self\fR (C, \*(C+, Objective-C and Objective\-\*(C+ only)" 4 .IX Item "-Winit-self (C, , Objective-C and Objective- only)" Warn about uninitialized variables which are initialized with themselves. Note this option can only be used with the \fB\-Wuninitialized\fR option, which in turn only works with \fB\-O1\fR and above. .Sp For example, \s-1GCC\s0 will warn about \f(CW\*(C`i\*(C'\fR being uninitialized in the following snippet only when \fB\-Winit\-self\fR has been specified: .Sp .Vb 5 \& int f() \& { \& int i = i; \& return i; \& } .Ve .IP "\fB\-Wimplicit\-int\fR (C and Objective-C only)" 4 .IX Item "-Wimplicit-int (C and Objective-C only)" Warn when a declaration does not specify a type. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wimplicit\-function\-declaration\fR (C and Objective-C only)" 4 .IX Item "-Wimplicit-function-declaration (C and Objective-C only)" Give a warning whenever a function is used before being declared. In C99 mode (\fB\-std=c99\fR or \fB\-std=gnu99\fR), this warning is enabled by default and it is made into an error by \&\fB\-pedantic\-errors\fR. This warning is also enabled by \&\fB\-Wall\fR. .IP "\fB\-Wimplicit\fR" 4 .IX Item "-Wimplicit" Same as \fB\-Wimplicit\-int\fR and \fB\-Wimplicit\-function\-declaration\fR. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wignored\-qualifiers\fR (C and \*(C+ only)" 4 .IX Item "-Wignored-qualifiers (C and only)" Warn if the return type of a function has a type qualifier such as \f(CW\*(C`const\*(C'\fR. For \s-1ISO\s0 C such a type qualifier has no effect, since the value returned by a function is not an lvalue. For \*(C+, the warning is only emitted for scalar types or \f(CW\*(C`void\*(C'\fR. \&\s-1ISO\s0 C prohibits qualified \f(CW\*(C`void\*(C'\fR return types on function definitions, so such return types always receive a warning even without this option. .Sp This warning is also enabled by \fB\-Wextra\fR. .IP "\fB\-Wmain\fR" 4 .IX Item "-Wmain" Warn if the type of \fBmain\fR is suspicious. \fBmain\fR should be a function with external linkage, returning int, taking either zero arguments, two, or three arguments of appropriate types. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wmissing\-braces\fR" 4 .IX Item "-Wmissing-braces" Warn if an aggregate or union initializer is not fully bracketed. In the following example, the initializer for \fBa\fR is not fully bracketed, but that for \fBb\fR is fully bracketed. .Sp .Vb 2 \& int a[2][2] = { 0, 1, 2, 3 }; \& int b[2][2] = { { 0, 1 }, { 2, 3 } }; .Ve .Sp This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wmissing\-include\-dirs\fR (C, \*(C+, Objective-C and Objective\-\*(C+ only)" 4 .IX Item "-Wmissing-include-dirs (C, , Objective-C and Objective- only)" Warn if a user-supplied include directory does not exist. .IP "\fB\-Wparentheses\fR" 4 .IX Item "-Wparentheses" Warn if parentheses are omitted in certain contexts, such as when there is an assignment in a context where a truth value is expected, or when operators are nested whose precedence people often get confused about. .Sp Also warn if a comparison like \fBx<=y<=z\fR appears; this is equivalent to \fB(x<=y ? 1 : 0) <= z\fR, which is a different interpretation from that of ordinary mathematical notation. .Sp Also warn about constructions where there may be confusion to which \&\f(CW\*(C`if\*(C'\fR statement an \f(CW\*(C`else\*(C'\fR branch belongs. Here is an example of such a case: .Sp .Vb 7 \& { \& if (a) \& if (b) \& foo (); \& else \& bar (); \& } .Ve .Sp In C/\*(C+, every \f(CW\*(C`else\*(C'\fR branch belongs to the innermost possible \&\f(CW\*(C`if\*(C'\fR statement, which in this example is \f(CW\*(C`if (b)\*(C'\fR. This is often not what the programmer expected, as illustrated in the above example by indentation the programmer chose. When there is the potential for this confusion, \s-1GCC\s0 will issue a warning when this flag is specified. To eliminate the warning, add explicit braces around the innermost \f(CW\*(C`if\*(C'\fR statement so there is no way the \f(CW\*(C`else\*(C'\fR could belong to the enclosing \f(CW\*(C`if\*(C'\fR. The resulting code would look like this: .Sp .Vb 9 \& { \& if (a) \& { \& if (b) \& foo (); \& else \& bar (); \& } \& } .Ve .Sp This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wsequence\-point\fR" 4 .IX Item "-Wsequence-point" Warn about code that may have undefined semantics because of violations of sequence point rules in the C and \*(C+ standards. .Sp The C and \*(C+ standards defines the order in which expressions in a C/\*(C+ program are evaluated in terms of \fIsequence points\fR, which represent a partial ordering between the execution of parts of the program: those executed before the sequence point, and those executed after it. These occur after the evaluation of a full expression (one which is not part of a larger expression), after the evaluation of the first operand of a \&\f(CW\*(C`&&\*(C'\fR, \f(CW\*(C`||\*(C'\fR, \f(CW\*(C`? :\*(C'\fR or \f(CW\*(C`,\*(C'\fR (comma) operator, before a function is called (but after the evaluation of its arguments and the expression denoting the called function), and in certain other places. Other than as expressed by the sequence point rules, the order of evaluation of subexpressions of an expression is not specified. All these rules describe only a partial order rather than a total order, since, for example, if two functions are called within one expression with no sequence point between them, the order in which the functions are called is not specified. However, the standards committee have ruled that function calls do not overlap. .Sp It is not specified when between sequence points modifications to the values of objects take effect. Programs whose behavior depends on this have undefined behavior; the C and \*(C+ standards specify that \*(L"Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be read only to determine the value to be stored.\*(R". If a program breaks these rules, the results on any particular implementation are entirely unpredictable. .Sp Examples of code with undefined behavior are \f(CW\*(C`a = a++;\*(C'\fR, \f(CW\*(C`a[n] = b[n++]\*(C'\fR and \f(CW\*(C`a[i++] = i;\*(C'\fR. Some more complicated cases are not diagnosed by this option, and it may give an occasional false positive result, but in general it has been found fairly effective at detecting this sort of problem in programs. .Sp The standard is worded confusingly, therefore there is some debate over the precise meaning of the sequence point rules in subtle cases. Links to discussions of the problem, including proposed formal definitions, may be found on the \s-1GCC\s0 readings page, at <\fBhttp://gcc.gnu.org/readings.html\fR>. .Sp This warning is enabled by \fB\-Wall\fR for C and \*(C+. .IP "\fB\-Wreturn\-type\fR" 4 .IX Item "-Wreturn-type" Warn whenever a function is defined with a return-type that defaults to \f(CW\*(C`int\*(C'\fR. Also warn about any \f(CW\*(C`return\*(C'\fR statement with no return-value in a function whose return-type is not \f(CW\*(C`void\*(C'\fR (falling off the end of the function body is considered returning without a value), and about a \f(CW\*(C`return\*(C'\fR statement with a expression in a function whose return-type is \f(CW\*(C`void\*(C'\fR. .Sp For \*(C+, a function without return type always produces a diagnostic message, even when \fB\-Wno\-return\-type\fR is specified. The only exceptions are \fBmain\fR and functions defined in system headers. .Sp This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wswitch\fR" 4 .IX Item "-Wswitch" Warn whenever a \f(CW\*(C`switch\*(C'\fR statement has an index of enumerated type and lacks a \f(CW\*(C`case\*(C'\fR for one or more of the named codes of that enumeration. (The presence of a \f(CW\*(C`default\*(C'\fR label prevents this warning.) \f(CW\*(C`case\*(C'\fR labels outside the enumeration range also provoke warnings when this option is used. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wswitch\-default\fR" 4 .IX Item "-Wswitch-default" Warn whenever a \f(CW\*(C`switch\*(C'\fR statement does not have a \f(CW\*(C`default\*(C'\fR case. .IP "\fB\-Wswitch\-enum\fR" 4 .IX Item "-Wswitch-enum" Warn whenever a \f(CW\*(C`switch\*(C'\fR statement has an index of enumerated type and lacks a \f(CW\*(C`case\*(C'\fR for one or more of the named codes of that enumeration. \f(CW\*(C`case\*(C'\fR labels outside the enumeration range also provoke warnings when this option is used. .IP "\fB\-Wtrigraphs\fR" 4 .IX Item "-Wtrigraphs" Warn if any trigraphs are encountered that might change the meaning of the program (trigraphs within comments are not warned about). This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wunused\-function\fR" 4 .IX Item "-Wunused-function" Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wunused\-label\fR" 4 .IX Item "-Wunused-label" Warn whenever a label is declared but not used. This warning is enabled by \fB\-Wall\fR. .Sp To suppress this warning use the \fBunused\fR attribute. .IP "\fB\-Wunused\-parameter\fR" 4 .IX Item "-Wunused-parameter" Warn whenever a function parameter is unused aside from its declaration. .Sp To suppress this warning use the \fBunused\fR attribute. .IP "\fB\-Wunused\-variable\fR" 4 .IX Item "-Wunused-variable" Warn whenever a local variable or non-constant static variable is unused aside from its declaration. This warning is enabled by \fB\-Wall\fR. .Sp To suppress this warning use the \fBunused\fR attribute. .IP "\fB\-Wunused\-value\fR" 4 .IX Item "-Wunused-value" Warn whenever a statement computes a result that is explicitly not used. To suppress this warning cast the unused expression to \&\fBvoid\fR. This includes an expression-statement or the left-hand side of a comma expression that contains no side effects. For example, an expression such as \fBx[i,j]\fR will cause a warning, while \&\fBx[(void)i,j]\fR will not. .Sp This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wunused\fR" 4 .IX Item "-Wunused" All the above \fB\-Wunused\fR options combined. .Sp In order to get a warning about an unused function parameter, you must either specify \fB\-Wextra \-Wunused\fR (note that \fB\-Wall\fR implies \&\fB\-Wunused\fR), or separately specify \fB\-Wunused\-parameter\fR. .IP "\fB\-Wuninitialized\fR" 4 .IX Item "-Wuninitialized" Warn if an automatic variable is used without first being initialized or if a variable may be clobbered by a \f(CW\*(C`setjmp\*(C'\fR call. .Sp These warnings are possible only in optimizing compilation, because they require data flow information that is computed only when optimizing. If you do not specify \fB\-O\fR, you will not get these warnings. Instead, \s-1GCC\s0 will issue a warning about \fB\-Wuninitialized\fR requiring \fB\-O\fR. .Sp If you want to warn about code which uses the uninitialized value of the variable in its own initializer, use the \fB\-Winit\-self\fR option. .Sp These warnings occur for individual uninitialized or clobbered elements of structure, union or array variables as well as for variables which are uninitialized or clobbered as a whole. They do not occur for variables or elements declared \f(CW\*(C`volatile\*(C'\fR. Because these warnings depend on optimization, the exact variables or elements for which there are warnings will depend on the precise optimization options and version of \s-1GCC\s0 used. .Sp Note that there may be no warning about a variable that is used only to compute a value that itself is never used, because such computations may be deleted by data flow analysis before the warnings are printed. .Sp These warnings are made optional because \s-1GCC\s0 is not smart enough to see all the reasons why the code might be correct despite appearing to have an error. Here is one example of how this can happen: .Sp .Vb 12 \& { \& int x; \& switch (y) \& { \& case 1: x = 1; \& break; \& case 2: x = 4; \& break; \& case 3: x = 5; \& } \& foo (x); \& } .Ve .Sp If the value of \f(CW\*(C`y\*(C'\fR is always 1, 2 or 3, then \f(CW\*(C`x\*(C'\fR is always initialized, but \s-1GCC\s0 doesn't know this. Here is another common case: .Sp .Vb 6 \& { \& int save_y; \& if (change_y) save_y = y, y = new_y; \& ... \& if (change_y) y = save_y; \& } .Ve .Sp This has no bug because \f(CW\*(C`save_y\*(C'\fR is used only if it is set. .Sp This option also warns when a non-volatile automatic variable might be changed by a call to \f(CW\*(C`longjmp\*(C'\fR. These warnings as well are possible only in optimizing compilation. .Sp The compiler sees only the calls to \f(CW\*(C`setjmp\*(C'\fR. It cannot know where \f(CW\*(C`longjmp\*(C'\fR will be called; in fact, a signal handler could call it at any point in the code. As a result, you may get a warning even when there is in fact no problem because \f(CW\*(C`longjmp\*(C'\fR cannot in fact be called at the place which would cause a problem. .Sp Some spurious warnings can be avoided if you declare all the functions you use that never return as \f(CW\*(C`noreturn\*(C'\fR. .Sp This warning is enabled by \fB\-Wall\fR or \fB\-Wextra\fR in optimizing compilations (\fB\-O1\fR and above). .IP "\fB\-Wunknown\-pragmas\fR" 4 .IX Item "-Wunknown-pragmas" Warn when a #pragma directive is encountered which is not understood by \&\s-1GCC\s0. If this command line option is used, warnings will even be issued for unknown pragmas in system header files. This is not the case if the warnings were only enabled by the \fB\-Wall\fR command line option. .IP "\fB\-Wno\-pragmas\fR" 4 .IX Item "-Wno-pragmas" Do not warn about misuses of pragmas, such as incorrect parameters, invalid syntax, or conflicts between pragmas. See also \&\fB\-Wunknown\-pragmas\fR. .IP "\fB\-Wstrict\-aliasing\fR" 4 .IX Item "-Wstrict-aliasing" This option is only active when \fB\-fstrict\-aliasing\fR is active. It warns about code which might break the strict aliasing rules that the compiler is using for optimization. The warning does not catch all cases, but does attempt to catch the more common pitfalls. It is included in \fB\-Wall\fR. It is equivalent to \fB\-Wstrict\-aliasing=3\fR .IP "\fB\-Wstrict\-aliasing=n\fR" 4 .IX Item "-Wstrict-aliasing=n" This option is only active when \fB\-fstrict\-aliasing\fR is active. It warns about code which might break the strict aliasing rules that the compiler is using for optimization. Higher levels correspond to higher accuracy (fewer false positives). Higher levels also correspond to more effort, similar to the way \-O works. \&\fB\-Wstrict\-aliasing\fR is equivalent to \fB\-Wstrict\-aliasing=n\fR, with n=3. .Sp Level 1: Most aggressive, quick, least accurate. Possibly useful when higher levels do not warn but \-fstrict\-aliasing still breaks the code, as it has very few false negatives. However, it has many false positives. Warns for all pointer conversions between possibly incompatible types, even if never dereferenced. Runs in the frontend only. .Sp Level 2: Aggressive, quick, not too precise. May still have many false positives (not as many as level 1 though), and few false negatives (but possibly more than level 1). Unlike level 1, it only warns when an address is taken. Warns about incomplete types. Runs in the frontend only. .Sp Level 3 (default for \fB\-Wstrict\-aliasing\fR): Should have very few false positives and few false negatives. Slightly slower than levels 1 or 2 when optimization is enabled. Takes care of the common punn+dereference pattern in the frontend: \&\f(CW\*(C`*(int*)&some_float\*(C'\fR. If optimization is enabled, it also runs in the backend, where it deals with multiple statement cases using flow-sensitive points-to information. Only warns when the converted pointer is dereferenced. Does not warn about incomplete types. .IP "\fB\-Wstrict\-overflow\fR" 4 .IX Item "-Wstrict-overflow" .PD 0 .IP "\fB\-Wstrict\-overflow=\fR\fIn\fR" 4 .IX Item "-Wstrict-overflow=n" .PD This option is only active when \fB\-fstrict\-overflow\fR is active. It warns about cases where the compiler optimizes based on the assumption that signed overflow does not occur. Note that it does not warn about all cases where the code might overflow: it only warns about cases where the compiler implements some optimization. Thus this warning depends on the optimization level. .Sp An optimization which assumes that signed overflow does not occur is perfectly safe if the values of the variables involved are such that overflow never does, in fact, occur. Therefore this warning can easily give a false positive: a warning about code which is not actually a problem. To help focus on important issues, several warning levels are defined. No warnings are issued for the use of undefined signed overflow when estimating how many iterations a loop will require, in particular when determining whether a loop will be executed at all. .RS 4 .IP "\fB\-Wstrict\-overflow=1\fR" 4 .IX Item "-Wstrict-overflow=1" Warn about cases which are both questionable and easy to avoid. For example: \f(CW\*(C`x + 1 > x\*(C'\fR; with \fB\-fstrict\-overflow\fR, the compiler will simplify this to \f(CW1\fR. This level of \&\fB\-Wstrict\-overflow\fR is enabled by \fB\-Wall\fR; higher levels are not, and must be explicitly requested. .IP "\fB\-Wstrict\-overflow=2\fR" 4 .IX Item "-Wstrict-overflow=2" Also warn about other cases where a comparison is simplified to a constant. For example: \f(CW\*(C`abs (x) >= 0\*(C'\fR. This can only be simplified when \fB\-fstrict\-overflow\fR is in effect, because \&\f(CW\*(C`abs (INT_MIN)\*(C'\fR overflows to \f(CW\*(C`INT_MIN\*(C'\fR, which is less than zero. \fB\-Wstrict\-overflow\fR (with no level) is the same as \&\fB\-Wstrict\-overflow=2\fR. .IP "\fB\-Wstrict\-overflow=3\fR" 4 .IX Item "-Wstrict-overflow=3" Also warn about other cases where a comparison is simplified. For example: \f(CW\*(C`x + 1 > 1\*(C'\fR will be simplified to \f(CW\*(C`x > 0\*(C'\fR. .IP "\fB\-Wstrict\-overflow=4\fR" 4 .IX Item "-Wstrict-overflow=4" Also warn about other simplifications not covered by the above cases. For example: \f(CW\*(C`(x * 10) / 5\*(C'\fR will be simplified to \f(CW\*(C`x * 2\*(C'\fR. .IP "\fB\-Wstrict\-overflow=5\fR" 4 .IX Item "-Wstrict-overflow=5" Also warn about cases where the compiler reduces the magnitude of a constant involved in a comparison. For example: \f(CW\*(C`x + 2 > y\*(C'\fR will be simplified to \f(CW\*(C`x + 1 >= y\*(C'\fR. This is reported only at the highest warning level because this simplification applies to many comparisons, so this warning level will give a very large number of false positives. .RE .RS 4 .RE .IP "\fB\-Warray\-bounds\fR" 4 .IX Item "-Warray-bounds" This option is only active when \fB\-ftree\-vrp\fR is active (default for \-O2 and above). It warns about subscripts to arrays that are always out of bounds. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wno\-div\-by\-zero\fR" 4 .IX Item "-Wno-div-by-zero" Do not warn about compile-time integer division by zero. Floating point division by zero is not warned about, as it can be a legitimate way of obtaining infinities and NaNs. .IP "\fB\-Wsystem\-headers\fR" 4 .IX Item "-Wsystem-headers" Print warning messages for constructs found in system header files. Warnings from system headers are normally suppressed, on the assumption that they usually do not indicate real problems and would only make the compiler output harder to read. Using this command line option tells \&\s-1GCC\s0 to emit warnings from system headers as if they occurred in user code. However, note that using \fB\-Wall\fR in conjunction with this option will \fInot\fR warn about unknown pragmas in system headers\-\-\-for that, \fB\-Wunknown\-pragmas\fR must also be used. .IP "\fB\-Wfloat\-equal\fR" 4 .IX Item "-Wfloat-equal" Warn if floating point values are used in equality comparisons. .Sp The idea behind this is that sometimes it is convenient (for the programmer) to consider floating-point values as approximations to infinitely precise real numbers. If you are doing this, then you need to compute (by analyzing the code, or in some other way) the maximum or likely maximum error that the computation introduces, and allow for it when performing comparisons (and when producing output, but that's a different problem). In particular, instead of testing for equality, you would check to see whether the two values have ranges that overlap; and this is done with the relational operators, so equality comparisons are probably mistaken. .IP "\fB\-Wtraditional\fR (C and Objective-C only)" 4 .IX Item "-Wtraditional (C and Objective-C only)" Warn about certain constructs that behave differently in traditional and \&\s-1ISO\s0 C. Also warn about \s-1ISO\s0 C constructs that have no traditional C equivalent, and/or problematic constructs which should be avoided. .RS 4 .IP "\(bu" 4 Macro parameters that appear within string literals in the macro body. In traditional C macro replacement takes place within string literals, but does not in \s-1ISO\s0 C. .IP "\(bu" 4 In traditional C, some preprocessor directives did not exist. Traditional preprocessors would only consider a line to be a directive if the \fB#\fR appeared in column 1 on the line. Therefore \&\fB\-Wtraditional\fR warns about directives that traditional C understands but would ignore because the \fB#\fR does not appear as the first character on the line. It also suggests you hide directives like \&\fB#pragma\fR not understood by traditional C by indenting them. Some traditional implementations would not recognize \fB#elif\fR, so it suggests avoiding it altogether. .IP "\(bu" 4 A function-like macro that appears without arguments. .IP "\(bu" 4 The unary plus operator. .IP "\(bu" 4 The \fBU\fR integer constant suffix, or the \fBF\fR or \fBL\fR floating point constant suffixes. (Traditional C does support the \fBL\fR suffix on integer constants.) Note, these suffixes appear in macros defined in the system headers of most modern systems, e.g. the \fB_MIN\fR/\fB_MAX\fR macros in \f(CW\*(C`\*(C'\fR. Use of these macros in user code might normally lead to spurious warnings, however \s-1GCC\s0's integrated preprocessor has enough context to avoid warning in these cases. .IP "\(bu" 4 A function declared external in one block and then used after the end of the block. .IP "\(bu" 4 A \f(CW\*(C`switch\*(C'\fR statement has an operand of type \f(CW\*(C`long\*(C'\fR. .IP "\(bu" 4 A non\-\f(CW\*(C`static\*(C'\fR function declaration follows a \f(CW\*(C`static\*(C'\fR one. This construct is not accepted by some traditional C compilers. .IP "\(bu" 4 The \s-1ISO\s0 type of an integer constant has a different width or signedness from its traditional type. This warning is only issued if the base of the constant is ten. I.e. hexadecimal or octal values, which typically represent bit patterns, are not warned about. .IP "\(bu" 4 Usage of \s-1ISO\s0 string concatenation is detected. .IP "\(bu" 4 Initialization of automatic aggregates. .IP "\(bu" 4 Identifier conflicts with labels. Traditional C lacks a separate namespace for labels. .IP "\(bu" 4 Initialization of unions. If the initializer is zero, the warning is omitted. This is done under the assumption that the zero initializer in user code appears conditioned on e.g. \f(CW\*(C`_\|_STDC_\|_\*(C'\fR to avoid missing initializer warnings and relies on default initialization to zero in the traditional C case. .IP "\(bu" 4 Conversions by prototypes between fixed/floating point values and vice versa. The absence of these prototypes when compiling with traditional C would cause serious problems. This is a subset of the possible conversion warnings, for the full set use \fB\-Wtraditional\-conversion\fR. .IP "\(bu" 4 Use of \s-1ISO\s0 C style function definitions. This warning intentionally is \&\fInot\fR issued for prototype declarations or variadic functions because these \s-1ISO\s0 C features will appear in your code when using libiberty's traditional C compatibility macros, \f(CW\*(C`PARAMS\*(C'\fR and \&\f(CW\*(C`VPARAMS\*(C'\fR. This warning is also bypassed for nested functions because that feature is already a \s-1GCC\s0 extension and thus not relevant to traditional C compatibility. .RE .RS 4 .RE .IP "\fB\-Wtraditional\-conversion\fR (C and Objective-C only)" 4 .IX Item "-Wtraditional-conversion (C and Objective-C only)" Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of a prototype. This includes conversions of fixed point to floating and vice versa, and conversions changing the width or signedness of a fixed point argument except when the same as the default promotion. .IP "\fB\-Wdeclaration\-after\-statement\fR (C and Objective-C only)" 4 .IX Item "-Wdeclaration-after-statement (C and Objective-C only)" Warn when a declaration is found after a statement in a block. This construct, known from \*(C+, was introduced with \s-1ISO\s0 C99 and is by default allowed in \s-1GCC\s0. It is not supported by \s-1ISO\s0 C90 and was not supported by \&\s-1GCC\s0 versions before \s-1GCC\s0 3.0. .IP "\fB\-Wundef\fR" 4 .IX Item "-Wundef" Warn if an undefined identifier is evaluated in an \fB#if\fR directive. .IP "\fB\-Wno\-endif\-labels\fR" 4 .IX Item "-Wno-endif-labels" Do not warn whenever an \fB#else\fR or an \fB#endif\fR are followed by text. .IP "\fB\-Wshadow\fR" 4 .IX Item "-Wshadow" Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed. .IP "\fB\-Wlarger\-than\-\fR\fIlen\fR" 4 .IX Item "-Wlarger-than-len" Warn whenever an object of larger than \fIlen\fR bytes is defined. .IP "\fB\-Wunsafe\-loop\-optimizations\fR" 4 .IX Item "-Wunsafe-loop-optimizations" Warn if the loop cannot be optimized because the compiler could not assume anything on the bounds of the loop indices. With \&\fB\-funsafe\-loop\-optimizations\fR warn if the compiler made such assumptions. .IP "\fB\-Wpointer\-arith\fR" 4 .IX Item "-Wpointer-arith" Warn about anything that depends on the \*(L"size of\*(R" a function type or of \f(CW\*(C`void\*(C'\fR. \s-1GNU\s0 C assigns these types a size of 1, for convenience in calculations with \f(CW\*(C`void *\*(C'\fR pointers and pointers to functions. In \*(C+, warn also when an arithmetic operation involves \&\f(CW\*(C`NULL\*(C'\fR. This warning is also enabled by \fB\-pedantic\fR. .IP "\fB\-Wtype\-limits\fR" 4 .IX Item "-Wtype-limits" Warn if a comparison is always true or always false due to the limited range of the data type, but do not warn for constant expressions. For example, warn if an unsigned variable is compared against zero with \&\fB<\fR or \fB>=\fR. This warning is also enabled by \&\fB\-Wextra\fR. .IP "\fB\-Wbad\-function\-cast\fR (C and Objective-C only)" 4 .IX Item "-Wbad-function-cast (C and Objective-C only)" Warn whenever a function call is cast to a non-matching type. For example, warn if \f(CW\*(C`int malloc()\*(C'\fR is cast to \f(CW\*(C`anything *\*(C'\fR. .IP "\fB\-Wc++\-compat\fR (C and Objective-C only)" 4 .IX Item "-Wc++-compat (C and Objective-C only)" Warn about \s-1ISO\s0 C constructs that are outside of the common subset of \&\s-1ISO\s0 C and \s-1ISO\s0 \*(C+, e.g. request for implicit conversion from \&\f(CW\*(C`void *\*(C'\fR to a pointer to non\-\f(CW\*(C`void\*(C'\fR type. .IP "\fB\-Wc++0x\-compat\fR (\*(C+ and Objective\-\*(C+ only)" 4 .IX Item "-Wc++0x-compat ( and Objective- only)" Warn about \*(C+ constructs whose meaning differs between \s-1ISO\s0 \*(C+ 1998 and \&\s-1ISO\s0 \*(C+ 200x, e.g., identifiers in \s-1ISO\s0 \*(C+ 1998 that will become keywords in \s-1ISO\s0 \*(C+ 200x. This warning is enabled by \fB\-Wall\fR. .IP "\fB\-Wcast\-qual\fR" 4 .IX Item "-Wcast-qual" Warn whenever a pointer is cast so as to remove a type qualifier from the target type. For example, warn if a \f(CW\*(C`const char *\*(C'\fR is cast to an ordinary \f(CW\*(C`char *\*(C'\fR. .IP "\fB\-Wcast\-align\fR" 4 .IX Item "-Wcast-align" Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a \f(CW\*(C`char *\*(C'\fR is cast to an \f(CW\*(C`int *\*(C'\fR on machines where integers can only be accessed at two\- or four-byte boundaries. .IP "\fB\-Wwrite\-strings\fR" 4 .IX Item "-Wwrite-strings" When compiling C, give string constants the type \f(CW\*(C`const char[\f(CIlength\f(CW]\*(C'\fR so that copying the address of one into a non\-\f(CW\*(C`const\*(C'\fR \f(CW\*(C`char *\*(C'\fR pointer will get a warning; when compiling \*(C+, warn about the deprecated conversion from string literals to \f(CW\*(C`char *\*(C'\fR. This warning, by default, is enabled for \*(C+ programs. These warnings will help you find at compile time code that can try to write into a string constant, but only if you have been very careful about using \f(CW\*(C`const\*(C'\fR in declarations and prototypes. Otherwise, it will just be a nuisance; this is why we did not make \fB\-Wall\fR request these warnings. .IP "\fB\-Wclobbered\fR" 4 .IX Item "-Wclobbered" Warn for variables that might be changed by \fBlongjmp\fR or \&\fBvfork\fR. This warning is also enabled by \fB\-Wextra\fR. .IP "\fB\-Wconversion\fR" 4 .IX Item "-Wconversion" Warn for implicit conversions that may alter a value. This includes conversions between real and integer, like \f(CW\*(C`abs (x)\*(C'\fR when \&\f(CW\*(C`x\*(C'\fR is \f(CW\*(C`double\*(C'\fR; conversions between signed and unsigned, like \f(CW\*(C`unsigned ui = \-1\*(C'\fR; and conversions to smaller types, like \&\f(CW\*(C`sqrtf (M_PI)\*(C'\fR. Do not warn for explicit casts like \f(CW\*(C`abs ((int) x)\*(C'\fR and \f(CW\*(C`ui = (unsigned) \-1\*(C'\fR, or if the value is not changed by the conversion like in \f(CW\*(C`abs (2.0)\*(C'\fR. Warnings about conversions between signed and unsigned integers can be disabled by using \fB\-Wno\-sign\-conversion\fR. .Sp For \*(C+, also warn for conversions between \f(CW\*(C`NULL\*(C'\fR and non-pointer types; confusing overload resolution for user-defined conversions; and conversions that will never use a type conversion operator: conversions to \f(CW\*(C`void\*(C'\fR, the same type, a base class or a reference to them. Warnings about conversions between signed and unsigned integers are disabled by default in \*(C+ unless \&\fB\-Wsign\-conversion\fR is explicitly enabled. .IP "\fB\-Wempty\-body\fR" 4 .IX Item "-Wempty-body" Warn if an empty body occurs in an \fBif\fR, \fBelse\fR or \fBdo while\fR statement. Additionally, in \*(C+, warn when an empty body occurs in a \fBwhile\fR or \fBfor\fR statement with no whitespacing before the semicolon. This warning is also enabled by \fB\-Wextra\fR. .IP "\fB\-Wsign\-compare\fR" 4 .IX Item "-Wsign-compare" Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted to unsigned. This warning is also enabled by \fB\-Wextra\fR; to get the other warnings of \fB\-Wextra\fR without this warning, use \fB\-Wextra \-Wno\-sign\-compare\fR. .IP "\fB\-Wsign\-conversion\fR" 4 .IX Item "-Wsign-conversion" Warn for implicit conversions that may change the sign of an integer value, like assigning a signed integer expression to an unsigned integer variable. An explicit cast silences the warning. In C, this option is enabled also by \fB\-Wconversion\fR. .IP "\fB\-Waddress\fR" 4 .IX Item "-Waddress" Warn about suspicious uses of memory addresses. These include using the address of a function in a conditional expression, such as \&\f(CW\*(C`void func(void); if (func)\*(C'\fR, and comparisons against the memory address of a string literal, such as \f(CW\*(C`if (x == "abc")\*(C'\fR. Such uses typically indicate a programmer error: the address of a function always evaluates to true, so their use in a conditional usually indicate that the programmer forgot the parentheses in a function call; and comparisons against string literals result in unspecified behavior and are not portable in C, so they usually indicate that the programmer intended to use \f(CW\*(C`strcmp\*(C'\fR. This warning is enabled by \&\fB\-Wall\fR. .IP "\fB\-Wlogical\-op\fR" 4 .IX Item "-Wlogical-op" Warn about suspicious uses of logical operators in expressions. This includes using logical operators in contexts where a bit-wise operator is likely to be expected. .IP "\fB\-Waggregate\-return\fR" 4 .IX Item "-Waggregate-return" Warn if any functions that return structures or unions are defined or called. (In languages where you can return an array, this also elicits a warning.) .IP "\fB\-Wno\-attributes\fR" 4 .IX Item "-Wno-attributes" Do not warn if an unexpected \f(CW\*(C`_\|_attribute_\|_\*(C'\fR is used, such as unrecognized attributes, function attributes applied to variables, etc. This will not stop errors for incorrect use of supported attributes. .IP "\fB\-Wstrict\-prototypes\fR (C and Objective-C only)" 4 .IX Item "-Wstrict-prototypes (C and Objective-C only)" Warn if a function is declared or defined without specifying the argument types. (An old-style function definition is permitted without a warning if preceded by a declaration which specifies the argument types.) .IP "\fB\-Wold\-style\-declaration\fR (C and Objective-C only)" 4 .IX Item "-Wold-style-declaration (C and Objective-C only)" Warn for obsolescent usages, according to the C Standard, in a declaration. For example, warn if storage-class specifiers like \&\f(CW\*(C`static\*(C'\fR are not the first things in a declaration. This warning is also enabled by \fB\-Wextra\fR. .IP "\fB\-Wold\-style\-definition\fR (C and Objective-C only)" 4 .IX Item "-Wold-style-definition (C and Objective-C only)" Warn if an old-style function definition is used. A warning is given even if there is a previous prototype. .IP "\fB\-Wmissing\-parameter\-type\fR (C and Objective-C only)" 4 .IX Item "-Wmissing-parameter-type (C and Objective-C only)" A function parameter is declared without a type specifier in K&R\-style functions: .Sp .Vb 1 \& void foo(bar) { } .Ve .Sp This warning is also enabled by \fB\-Wextra\fR. .IP "\fB\-Wmissing\-prototypes\fR (C and Objective-C only)" 4 .IX Item "-Wmissing-prototypes (C and Objective-C only)" Warn if a global function is defined without a previous prototype declaration. This warning is issued even if the definition itself provides a prototype. The aim is to detect global functions that fail to be declared in header files. .IP "\fB\-Wmissing\-declarations\fR" 4 .IX Item "-Wmissing-declarations" Warn if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype. Use this option to detect global functions that are not declared in header files. In \*(C+, no warnings are issued for function templates, or for inline functions, or for functions in anonymous namespaces. .IP "\fB\-Wmissing\-field\-initializers\fR" 4 .IX Item "-Wmissing-field-initializers" Warn if a structure's initializer has some fields missing. For example, the following code would cause such a warning, because \&\f(CW\*(C`x.h\*(C'\fR is implicitly zero: .Sp .Vb 2 \& struct s { int f, g, h; }; \& struct s x = { 3, 4 }; .Ve .Sp This option does not warn about designated initializers, so the following modification would not trigger a warning: .Sp .Vb 2 \& struct s { int f, g, h; }; \& struct s x = { .f = 3, .g = 4 }; .Ve .Sp This warning is included in \fB\-Wextra\fR. To get other \fB\-Wextra\fR warnings without this one, use \fB\-Wextra \-Wno\-missing\-field\-initializers\fR. .IP "\fB\-Wmissing\-noreturn\fR" 4 .IX Item "-Wmissing-noreturn" Warn about functions which might be candidates for attribute \f(CW\*(C`noreturn\*(C'\fR. Note these are only possible candidates, not absolute ones. Care should be taken to manually verify functions actually do not ever return before adding the \f(CW\*(C`noreturn\*(C'\fR attribute, otherwise subtle code generation bugs could be introduced. You will not get a warning for \f(CW\*(C`main\*(C'\fR in hosted C environments. .IP "\fB\-Wmissing\-format\-attribute\fR" 4 .IX Item "-Wmissing-format-attribute" Warn about function pointers which might be candidates for \f(CW\*(C`format\*(C'\fR attributes. Note these are only possible candidates, not absolute ones. \&\s-1GCC\s0 will guess that function pointers with \f(CW\*(C`format\*(C'\fR attributes that are used in assignment, initialization, parameter passing or return statements should have a corresponding \f(CW\*(C`format\*(C'\fR attribute in the resulting type. I.e. the left-hand side of the assignment or initialization, the type of the parameter variable, or the return type of the containing function respectively should also have a \f(CW\*(C`format\*(C'\fR attribute to avoid the warning. .Sp \&\s-1GCC\s0 will also warn about function definitions which might be candidates for \f(CW\*(C`format\*(C'\fR attributes. Again, these are only possible candidates. \s-1GCC\s0 will guess that \f(CW\*(C`format\*(C'\fR attributes might be appropriate for any function that calls a function like \&\f(CW\*(C`vprintf\*(C'\fR or \f(CW\*(C`vscanf\*(C'\fR, but this might not always be the case, and some functions for which \f(CW\*(C`format\*(C'\fR attributes are appropriate may not be detected. .IP "\fB\-Wno\-multichar\fR" 4 .IX Item "-Wno-multichar" Do not warn if a multicharacter constant (\fB'\s-1FOOF\s0'\fR) is used. Usually they indicate a typo in the user's code, as they have implementation-defined values, and should not be used in portable code. .IP "\fB\-Wnormalized=\fR" 4 .IX Item "-Wnormalized=" In \s-1ISO\s0 C and \s-1ISO\s0 \*(C+, two identifiers are different if they are different sequences of characters. However, sometimes when characters outside the basic \s-1ASCII\s0 character set are used, you can have two different character sequences that look the same. To avoid confusion, the \s-1ISO\s0 10646 standard sets out some \fInormalization rules\fR which when applied ensure that two sequences that look the same are turned into the same sequence. \s-1GCC\s0 can warn you if you are using identifiers which have not been normalized; this option controls that warning. .Sp There are four levels of warning that \s-1GCC\s0 supports. The default is \&\fB\-Wnormalized=nfc\fR, which warns about any identifier which is not in the \s-1ISO\s0 10646 \*(L"C\*(R" normalized form, \fI\s-1NFC\s0\fR. \s-1NFC\s0 is the recommended form for most uses. .Sp Unfortunately, there are some characters which \s-1ISO\s0 C and \s-1ISO\s0 \*(C+ allow in identifiers that when turned into \s-1NFC\s0 aren't allowable as identifiers. That is, there's no way to use these symbols in portable \&\s-1ISO\s0 C or \*(C+ and have all your identifiers in \s-1NFC\s0. \&\fB\-Wnormalized=id\fR suppresses the warning for these characters. It is hoped that future versions of the standards involved will correct this, which is why this option is not the default. .Sp You can switch the warning off for all characters by writing \&\fB\-Wnormalized=none\fR. You would only want to do this if you were using some other normalization scheme (like \*(L"D\*(R"), because otherwise you can easily create bugs that are literally impossible to see. .Sp Some characters in \s-1ISO\s0 10646 have distinct meanings but look identical in some fonts or display methodologies, especially once formatting has been applied. For instance \f(CW\*(C`\eu207F\*(C'\fR, \*(L"\s-1SUPERSCRIPT\s0 \s-1LATIN\s0 \s-1SMALL\s0 \&\s-1LETTER\s0 N\*(R", will display just like a regular \f(CW\*(C`n\*(C'\fR which has been placed in a superscript. \s-1ISO\s0 10646 defines the \fI\s-1NFKC\s0\fR normalization scheme to convert all these into a standard form as well, and \s-1GCC\s0 will warn if your code is not in \s-1NFKC\s0 if you use \&\fB\-Wnormalized=nfkc\fR. This warning is comparable to warning about every identifier that contains the letter O because it might be confused with the digit 0, and so is not the default, but may be useful as a local coding convention if the programming environment is unable to be fixed to display these characters distinctly. .IP "\fB\-Wno\-deprecated\-declarations\fR" 4 .IX Item "-Wno-deprecated-declarations" Do not warn about uses of functions, variables, and types marked as deprecated by using the \f(CW\*(C`deprecated\*(C'\fR attribute. .IP "\fB\-Wno\-overflow\fR" 4 .IX Item "-Wno-overflow" Do not warn about compile-time overflow in constant expressions. .IP "\fB\-Woverride\-init\fR (C and Objective-C only)" 4 .IX Item "-Woverride-init (C and Objective-C only)" Warn if an initialized field without side effects is overridden when using designated initializers. .Sp This warning is included in \fB\-Wextra\fR. To get other \&\fB\-Wextra\fR warnings without this one, use \fB\-Wextra \&\-Wno\-override\-init\fR. .IP "\fB\-Wpacked\fR" 4 .IX Item "-Wpacked" Warn if a structure is given the packed attribute, but the packed attribute has no effect on the layout or size of the structure. Such structures may be mis-aligned for little benefit. For instance, in this code, the variable \f(CW\*(C`f.x\*(C'\fR in \f(CW\*(C`struct bar\*(C'\fR will be misaligned even though \f(CW\*(C`struct bar\*(C'\fR does not itself have the packed attribute: .Sp .Vb 8 \& struct foo { \& int x; \& char a, b, c, d; \& } _\|_attribute_\|_((packed)); \& struct bar { \& char z; \& struct foo f; \& }; .Ve .IP "\fB\-Wpadded\fR" 4 .IX Item "-Wpadded" Warn if padding is included in a structure, either to align an element of the structure or to align the whole structure. Sometimes when this happens it is possible to rearrange the fields of the structure to reduce the padding and so make the structure smaller. .IP "\fB\-Wredundant\-decls\fR" 4 .IX Item "-Wredundant-decls" Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing. .IP "\fB\-Wnested\-externs\fR (C and Objective-C only)" 4 .IX Item "-Wnested-externs (C and Objective-C only)" Warn if an \f(CW\*(C`extern\*(C'\fR declaration is encountered within a function. .IP "\fB\-Wunreachable\-code\fR" 4 .IX Item "-Wunreachable-code" Warn if the compiler detects that code will never be executed. .Sp This option is intended to warn when the compiler detects that at least a whole line of source code will never be executed, because some condition is never satisfied or because it is after a procedure that never returns. .Sp It is possible for this option to produce a warning even though there are circumstances under which part of the affected line can be executed, so care should be taken when removing apparently-unreachable code. .Sp For instance, when a function is inlined, a warning may mean that the line is unreachable in only one inlined copy of the function. .Sp This option is not made part of \fB\-Wall\fR because in a debugging version of a program there is often substantial code which checks correct functioning of the program and is, hopefully, unreachable because the program does work. Another common use of unreachable code is to provide behavior which is selectable at compile-time. .IP "\fB\-Winline\fR" 4 .IX Item "-Winline" Warn if a function can not be inlined and it was declared as inline. Even with this option, the compiler will not warn about failures to inline functions declared in system headers. .Sp The compiler uses a variety of heuristics to determine whether or not to inline a function. For example, the compiler takes into account the size of the function being inlined and the amount of inlining that has already been done in the current function. Therefore, seemingly insignificant changes in the source program can cause the warnings produced by \fB\-Winline\fR to appear or disappear. .IP "\fB\-Wno\-invalid\-offsetof\fR (\*(C+ and Objective\-\*(C+ only)" 4 .IX Item "-Wno-invalid-offsetof ( and Objective- only)" Suppress warnings from applying the \fBoffsetof\fR macro to a non-POD type. According to the 1998 \s-1ISO\s0 \*(C+ standard, applying \fBoffsetof\fR to a non-POD type is undefined. In existing \*(C+ implementations, however, \fBoffsetof\fR typically gives meaningful results even when applied to certain kinds of non-POD types. (Such as a simple \&\fBstruct\fR that fails to be a \s-1POD\s0 type only by virtue of having a constructor.) This flag is for users who are aware that they are writing nonportable code and who have deliberately chosen to ignore the warning about it. .Sp The restrictions on \fBoffsetof\fR may be relaxed in a future version of the \*(C+ standard. .IP "\fB\-Wno\-int\-to\-pointer\-cast\fR (C and Objective-C only)" 4 .IX Item "-Wno-int-to-pointer-cast (C and Objective-C only)" Suppress warnings from casts to pointer type of an integer of a different size. .IP "\fB\-Wno\-pointer\-to\-int\-cast\fR (C and Objective-C only)" 4 .IX Item "-Wno-pointer-to-int-cast (C and Objective-C only)" Suppress warnings from casts from a pointer to an integer type of a different size. .IP "\fB\-Winvalid\-pch\fR" 4 .IX Item "-Winvalid-pch" Warn if a precompiled header is found in the search path but can't be used. .IP "\fB\-Wlong\-long\fR" 4 .IX Item "-Wlong-long" Warn if \fBlong long\fR type is used. This is default. To inhibit the warning messages, use \fB\-Wno\-long\-long\fR. Flags \&\fB\-Wlong\-long\fR and \fB\-Wno\-long\-long\fR are taken into account only when \fB\-pedantic\fR flag is used. .IP "\fB\-Wvariadic\-macros\fR" 4 .IX Item "-Wvariadic-macros" Warn if variadic macros are used in pedantic \s-1ISO\s0 C90 mode, or the \s-1GNU\s0 alternate syntax when in pedantic \s-1ISO\s0 C99 mode. This is default. To inhibit the warning messages, use \fB\-Wno\-variadic\-macros\fR. .IP "\fB\-Wvla\fR" 4 .IX Item "-Wvla" Warn if variable length array is used in the code. \&\fB\-Wno\-vla\fR will prevent the \fB\-pedantic\fR warning of the variable length array. .IP "\fB\-Wvolatile\-register\-var\fR" 4 .IX Item "-Wvolatile-register-var" Warn if a register variable is declared volatile. The volatile modifier does not inhibit all optimizations that may eliminate reads and/or writes to register variables. .IP "\fB\-Wdisabled\-optimization\fR" 4 .IX Item "-Wdisabled-optimization" Warn if a requested optimization pass is disabled. This warning does not generally indicate that there is anything wrong with your code; it merely indicates that \s-1GCC\s0's optimizers were unable to handle the code effectively. Often, the problem is that your code is too big or too complex; \s-1GCC\s0 will refuse to optimize programs when the optimization itself is likely to take inordinate amounts of time. .IP "\fB\-Wpointer\-sign\fR (C and Objective-C only)" 4 .IX Item "-Wpointer-sign (C and Objective-C only)" Warn for pointer argument passing or assignment with different signedness. This option is only supported for C and Objective-C. It is implied by \&\fB\-Wall\fR and by \fB\-pedantic\fR, which can be disabled with \&\fB\-Wno\-pointer\-sign\fR. .IP "\fB\-Wstack\-protector\fR" 4 .IX Item "-Wstack-protector" This option is only active when \fB\-fstack\-protector\fR is active. It warns about functions that will not be protected against stack smashing. .IP "\fB\-Woverlength\-strings\fR" 4 .IX Item "-Woverlength-strings" Warn about string constants which are longer than the \*(L"mini