• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2011.09/share/doc/arm-arm-none-eabi/html/gcc/
1<html lang="en">
2<head>
3<title>Warning Options - Using the GNU Compiler Collection (GCC)</title>
4<meta http-equiv="Content-Type" content="text/html">
5<meta name="description" content="Using the GNU Compiler Collection (GCC)">
6<meta name="generator" content="makeinfo 4.13">
7<link title="Top" rel="start" href="index.html#Top">
8<link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC">
9<link rel="prev" href="Language-Independent-Options.html#Language-Independent-Options" title="Language Independent Options">
10<link rel="next" href="Debugging-Options.html#Debugging-Options" title="Debugging Options">
11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
12<!--
13Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
141998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
152010 Free Software Foundation, Inc.
16
17Permission is granted to copy, distribute and/or modify this document
18under the terms of the GNU Free Documentation License, Version 1.3 or
19any later version published by the Free Software Foundation; with the
20Invariant Sections being ``Funding Free Software'', the Front-Cover
21Texts being (a) (see below), and with the Back-Cover Texts being (b)
22(see below).  A copy of the license is included in the section entitled
23``GNU Free Documentation License''.
24
25(a) The FSF's Front-Cover Text is:
26
27     A GNU Manual
28
29(b) The FSF's Back-Cover Text is:
30
31     You have freedom to copy and modify this GNU Manual, like GNU
32     software.  Copies published by the Free Software Foundation raise
33     funds for GNU development.-->
34<meta http-equiv="Content-Style-Type" content="text/css">
35<style type="text/css"><!--
36  pre.display { font-family:inherit }
37  pre.format  { font-family:inherit }
38  pre.smalldisplay { font-family:inherit; font-size:smaller }
39  pre.smallformat  { font-family:inherit; font-size:smaller }
40  pre.smallexample { font-size:smaller }
41  pre.smalllisp    { font-size:smaller }
42  span.sc    { font-variant:small-caps }
43  span.roman { font-family:serif; font-weight:normal; } 
44  span.sansserif { font-family:sans-serif; font-weight:normal; } 
45--></style>
46<link rel="stylesheet" type="text/css" href="../cs.css">
47</head>
48<body>
49<div class="node">
50<a name="Warning-Options"></a>
51<p>
52Next:&nbsp;<a rel="next" accesskey="n" href="Debugging-Options.html#Debugging-Options">Debugging Options</a>,
53Previous:&nbsp;<a rel="previous" accesskey="p" href="Language-Independent-Options.html#Language-Independent-Options">Language Independent Options</a>,
54Up:&nbsp;<a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a>
55<hr>
56</div>
57
58<h3 class="section">3.8 Options to Request or Suppress Warnings</h3>
59
60<p><a name="index-options-to-control-warnings-230"></a><a name="index-warning-messages-231"></a><a name="index-messages_002c-warning-232"></a><a name="index-suppressing-warnings-233"></a>
61Warnings are diagnostic messages that report constructions which
62are not inherently erroneous but which are risky or suggest there
63may have been an error.
64
65 <p>The following language-independent options do not enable specific
66warnings but control the kinds of diagnostics produced by GCC.
67
68     
69<a name="index-syntax-checking-234"></a>
70<dl><dt><code>-fsyntax-only</code><dd><a name="index-fsyntax_002donly-235"></a>Check the code for syntax errors, but don't do anything beyond that.
71
72     <br><dt><code>-fmax-errors=</code><var>n</var><dd><a name="index-fmax_002derrors-236"></a>Limits the maximum number of error messages to <var>n</var>, at which point
73GCC bails out rather than attempting to continue processing the source
74code.  If <var>n</var> is 0 (the default), there is no limit on the number
75of error messages produced.  If <samp><span class="option">-Wfatal-errors</span></samp> is also
76specified, then <samp><span class="option">-Wfatal-errors</span></samp> takes precedence over this
77option.
78
79     <br><dt><code>-w</code><dd><a name="index-w-237"></a>Inhibit all warning messages.
80
81     <br><dt><code>-Werror</code><dd><a name="index-Werror-238"></a><a name="index-Wno_002derror-239"></a>Make all warnings into errors.
82
83     <br><dt><code>-Werror=</code><dd><a name="index-Werror_003d-240"></a><a name="index-Wno_002derror_003d-241"></a>Make the specified warning into an error.  The specifier for a warning
84is appended, for example <samp><span class="option">-Werror=switch</span></samp> turns the warnings
85controlled by <samp><span class="option">-Wswitch</span></samp> into errors.  This switch takes a
86negative form, to be used to negate <samp><span class="option">-Werror</span></samp> for specific
87warnings, for example <samp><span class="option">-Wno-error=switch</span></samp> makes
88<samp><span class="option">-Wswitch</span></samp> warnings not be errors, even when <samp><span class="option">-Werror</span></samp>
89is in effect.
90
91     <p>The warning message for each controllable warning includes the
92option which controls the warning.  That option can then be used with
93<samp><span class="option">-Werror=</span></samp> and <samp><span class="option">-Wno-error=</span></samp> as described above. 
94(Printing of the option in the warning message can be disabled using the
95<samp><span class="option">-fno-diagnostics-show-option</span></samp> flag.)
96
97     <p>Note that specifying <samp><span class="option">-Werror=</span></samp><var>foo</var> automatically implies
98<samp><span class="option">-W</span></samp><var>foo</var>.  However, <samp><span class="option">-Wno-error=</span></samp><var>foo</var> does not
99imply anything.
100
101     <br><dt><code>-Wfatal-errors</code><dd><a name="index-Wfatal_002derrors-242"></a><a name="index-Wno_002dfatal_002derrors-243"></a>This option causes the compiler to abort compilation on the first error
102occurred rather than trying to keep going and printing further error
103messages.
104
105 </dl>
106
107 <p>You can request many specific warnings with options beginning
108&lsquo;<samp><span class="samp">-W</span></samp>&rsquo;, for example <samp><span class="option">-Wimplicit</span></samp> to request warnings on
109implicit declarations.  Each of these specific warning options also
110has a negative form beginning &lsquo;<samp><span class="samp">-Wno-</span></samp>&rsquo; to turn off warnings; for
111example, <samp><span class="option">-Wno-implicit</span></samp>.  This manual lists only one of the
112two forms, whichever is not the default.  For further,
113language-specific options also refer to <a href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options">C++ Dialect Options</a> and
114<a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options">Objective-C and Objective-C++ Dialect Options</a>.
115
116 <p>When an unrecognized warning option is requested (e.g.,
117<samp><span class="option">-Wunknown-warning</span></samp>), GCC will emit a diagnostic stating
118that the option is not recognized.  However, if the <samp><span class="option">-Wno-</span></samp> form
119is used, the behavior is slightly different: No diagnostic will be
120produced for <samp><span class="option">-Wno-unknown-warning</span></samp> unless other diagnostics
121are being produced.  This allows the use of new <samp><span class="option">-Wno-</span></samp> options
122with old compilers, but if something goes wrong, the compiler will
123warn that an unrecognized option was used.
124
125     <dl>
126<dt><code>-pedantic</code><dd><a name="index-pedantic-244"></a>Issue all the warnings demanded by strict ISO C and ISO C++;
127reject all programs that use forbidden extensions, and some other
128programs that do not follow ISO C and ISO C++.  For ISO C, follows the
129version of the ISO C standard specified by any <samp><span class="option">-std</span></samp> option used.
130
131     <p>Valid ISO C and ISO C++ programs should compile properly with or without
132this option (though a rare few will require <samp><span class="option">-ansi</span></samp> or a
133<samp><span class="option">-std</span></samp> option specifying the required version of ISO C).  However,
134without this option, certain GNU extensions and traditional C and C++
135features are supported as well.  With this option, they are rejected.
136
137     <p><samp><span class="option">-pedantic</span></samp> does not cause warning messages for use of the
138alternate keywords whose names begin and end with &lsquo;<samp><span class="samp">__</span></samp>&rsquo;.  Pedantic
139warnings are also disabled in the expression that follows
140<code>__extension__</code>.  However, only system header files should use
141these escape routes; application programs should avoid them. 
142See <a href="Alternate-Keywords.html#Alternate-Keywords">Alternate Keywords</a>.
143
144     <p>Some users try to use <samp><span class="option">-pedantic</span></samp> to check programs for strict ISO
145C conformance.  They soon find that it does not do quite what they want:
146it finds some non-ISO practices, but not all&mdash;only those for which
147ISO C <em>requires</em> a diagnostic, and some others for which
148diagnostics have been added.
149
150     <p>A feature to report any failure to conform to ISO C might be useful in
151some instances, but would require considerable additional work and would
152be quite different from <samp><span class="option">-pedantic</span></samp>.  We don't have plans to
153support such a feature in the near future.
154
155     <p>Where the standard specified with <samp><span class="option">-std</span></samp> represents a GNU
156extended dialect of C, such as &lsquo;<samp><span class="samp">gnu90</span></samp>&rsquo; or &lsquo;<samp><span class="samp">gnu99</span></samp>&rsquo;, there is a
157corresponding <dfn>base standard</dfn>, the version of ISO C on which the GNU
158extended dialect is based.  Warnings from <samp><span class="option">-pedantic</span></samp> are given
159where they are required by the base standard.  (It would not make sense
160for such warnings to be given only for features not in the specified GNU
161C dialect, since by definition the GNU dialects of C include all
162features the compiler supports with the given option, and there would be
163nothing to warn about.)
164
165     <br><dt><code>-pedantic-errors</code><dd><a name="index-pedantic_002derrors-245"></a>Like <samp><span class="option">-pedantic</span></samp>, except that errors are produced rather than
166warnings.
167
168     <br><dt><code>-Wall</code><dd><a name="index-Wall-246"></a><a name="index-Wno_002dall-247"></a>This enables all the warnings about constructions that some users
169consider questionable, and that are easy to avoid (or modify to
170prevent the warning), even in conjunction with macros.  This also
171enables some language-specific warnings described in <a href="C_002b_002b-Dialect-Options.html#C_002b_002b-Dialect-Options">C++ Dialect Options</a> and <a href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options">Objective-C and Objective-C++ Dialect Options</a>.
172
173     <p><samp><span class="option">-Wall</span></samp> turns on the following warning flags:
174
175     <pre class="smallexample">          -Waddress   
176          -Warray-bounds <span class="roman">(only with</span> <samp><span class="option">-O2</span></samp><span class="roman">)</span>  
177          -Wc++0x-compat  
178          -Wchar-subscripts  
179          -Wenum-compare <span class="roman">(in C/Objc; this is on by default in C++)</span> 
180          -Wimplicit-int <span class="roman">(C and Objective-C only)</span> 
181          -Wimplicit-function-declaration <span class="roman">(C and Objective-C only)</span> 
182          -Wcomment  
183          -Wformat   
184          -Wmain <span class="roman">(only for C/ObjC and unless</span> <samp><span class="option">-ffreestanding</span></samp><span class="roman">)</span>  
185          -Wmissing-braces  
186          -Wnonnull  
187          -Wparentheses  
188          -Wpointer-sign  
189          -Wreorder   
190          -Wreturn-type  
191          -Wsequence-point  
192          -Wsign-compare <span class="roman">(only in C++)</span>  
193          -Wstrict-aliasing  
194          -Wstrict-overflow=1  
195          -Wswitch  
196          -Wtrigraphs  
197          -Wuninitialized  
198          -Wunknown-pragmas  
199          -Wunused-function  
200          -Wunused-label     
201          -Wunused-value     
202          -Wunused-variable  
203          -Wvolatile-register-var 
204          
205</pre>
206     <p>Note that some warning flags are not implied by <samp><span class="option">-Wall</span></samp>.  Some of
207them warn about constructions that users generally do not consider
208questionable, but which occasionally you might wish to check for;
209others warn about constructions that are necessary or hard to avoid in
210some cases, and there is no simple way to modify the code to suppress
211the warning. Some of them are enabled by <samp><span class="option">-Wextra</span></samp> but many of
212them must be enabled individually.
213
214     <br><dt><code>-Wextra</code><dd><a name="index-W-248"></a><a name="index-Wextra-249"></a><a name="index-Wno_002dextra-250"></a>This enables some extra warning flags that are not enabled by
215<samp><span class="option">-Wall</span></samp>. (This option used to be called <samp><span class="option">-W</span></samp>.  The older
216name is still supported, but the newer name is more descriptive.)
217
218     <pre class="smallexample">          -Wclobbered  
219          -Wempty-body  
220          -Wignored-qualifiers 
221          -Wmissing-field-initializers  
222          -Wmissing-parameter-type <span class="roman">(C only)</span>  
223          -Wold-style-declaration <span class="roman">(C only)</span>  
224          -Woverride-init  
225          -Wsign-compare  
226          -Wtype-limits  
227          -Wuninitialized  
228          -Wunused-parameter <span class="roman">(only with</span> <samp><span class="option">-Wunused</span></samp> <span class="roman">or</span> <samp><span class="option">-Wall</span></samp><span class="roman">)</span> 
229          -Wunused-but-set-parameter <span class="roman">(only with</span> <samp><span class="option">-Wunused</span></samp> <span class="roman">or</span> <samp><span class="option">-Wall</span></samp><span class="roman">)</span>  
230          
231</pre>
232     <p>The option <samp><span class="option">-Wextra</span></samp> also prints warning messages for the
233following cases:
234
235          <ul>
236<li>A pointer is compared against integer zero with &lsquo;<samp><span class="samp">&lt;</span></samp>&rsquo;, &lsquo;<samp><span class="samp">&lt;=</span></samp>&rsquo;,
237&lsquo;<samp><span class="samp">&gt;</span></samp>&rsquo;, or &lsquo;<samp><span class="samp">&gt;=</span></samp>&rsquo;.
238
239          <li>(C++ only) An enumerator and a non-enumerator both appear in a
240conditional expression.
241
242          <li>(C++ only) Ambiguous virtual bases.
243
244          <li>(C++ only) Subscripting an array which has been declared &lsquo;<samp><span class="samp">register</span></samp>&rsquo;.
245
246          <li>(C++ only) Taking the address of a variable which has been declared
247&lsquo;<samp><span class="samp">register</span></samp>&rsquo;.
248
249          <li>(C++ only) A base class is not initialized in a derived class' copy
250constructor.
251
252     </ul>
253
254     <br><dt><code>-Wchar-subscripts</code><dd><a name="index-Wchar_002dsubscripts-251"></a><a name="index-Wno_002dchar_002dsubscripts-252"></a>Warn if an array subscript has type <code>char</code>.  This is a common cause
255of error, as programmers often forget that this type is signed on some
256machines. 
257This warning is enabled by <samp><span class="option">-Wall</span></samp>.
258
259     <br><dt><code>-Wcomment</code><dd><a name="index-Wcomment-253"></a><a name="index-Wno_002dcomment-254"></a>Warn whenever a comment-start sequence &lsquo;<samp><span class="samp">/*</span></samp>&rsquo; appears in a &lsquo;<samp><span class="samp">/*</span></samp>&rsquo;
260comment, or whenever a Backslash-Newline appears in a &lsquo;<samp><span class="samp">//</span></samp>&rsquo; comment. 
261This warning is enabled by <samp><span class="option">-Wall</span></samp>.
262
263     <br><dt><code>-Wno-cpp</code><dd><span class="roman">(C, Objective-C, C++, Objective-C++ and Fortran only)</span>
264
265     <p>Suppress warning messages emitted by <code>#warning</code> directives.
266
267     <br><dt><code>-Wdouble-promotion </code><span class="roman">(C, C++, Objective-C and Objective-C++ only)</span><dd><a name="index-Wdouble_002dpromotion-255"></a><a name="index-Wno_002ddouble_002dpromotion-256"></a>Give a warning when a value of type <code>float</code> is implicitly
268promoted to <code>double</code>.  CPUs with a 32-bit &ldquo;single-precision&rdquo;
269floating-point unit implement <code>float</code> in hardware, but emulate
270<code>double</code> in software.  On such a machine, doing computations
271using <code>double</code> values is much more expensive because of the
272overhead required for software emulation.
273
274     <p>It is easy to accidentally do computations with <code>double</code> because
275floating-point literals are implicitly of type <code>double</code>.  For
276example, in:
277     <pre class="smallexample">          float area(float radius)
278          {
279             return 3.14159 * radius * radius;
280          }
281</pre>
282     <p>the compiler will perform the entire computation with <code>double</code>
283because the floating-point literal is a <code>double</code>.
284
285     <br><dt><code>-Wformat</code><dd><a name="index-Wformat-257"></a><a name="index-Wno_002dformat-258"></a><a name="index-ffreestanding-259"></a><a name="index-fno_002dbuiltin-260"></a>Check calls to <code>printf</code> and <code>scanf</code>, etc., to make sure that
286the arguments supplied have types appropriate to the format string
287specified, and that the conversions specified in the format string make
288sense.  This includes standard functions, and others specified by format
289attributes (see <a href="Function-Attributes.html#Function-Attributes">Function Attributes</a>), in the <code>printf</code>,
290<code>scanf</code>, <code>strftime</code> and <code>strfmon</code> (an X/Open extension,
291not in the C standard) families (or other target-specific families). 
292Which functions are checked without format attributes having been
293specified depends on the standard version selected, and such checks of
294functions without the attribute specified are disabled by
295<samp><span class="option">-ffreestanding</span></samp> or <samp><span class="option">-fno-builtin</span></samp>.
296
297     <p>The formats are checked against the format features supported by GNU
298libc version 2.2.  These include all ISO C90 and C99 features, as well
299as features from the Single Unix Specification and some BSD and GNU
300extensions.  Other library implementations may not support all these
301features; GCC does not support warning about features that go beyond a
302particular library's limitations.  However, if <samp><span class="option">-pedantic</span></samp> is used
303with <samp><span class="option">-Wformat</span></samp>, warnings will be given about format features not
304in the selected standard version (but not for <code>strfmon</code> formats,
305since those are not in any version of the C standard).  See <a href="C-Dialect-Options.html#C-Dialect-Options">Options Controlling C Dialect</a>.
306
307     <p>Since <samp><span class="option">-Wformat</span></samp> also checks for null format arguments for
308several functions, <samp><span class="option">-Wformat</span></samp> also implies <samp><span class="option">-Wnonnull</span></samp>.
309
310     <p><samp><span class="option">-Wformat</span></samp> is included in <samp><span class="option">-Wall</span></samp>.  For more control over some
311aspects of format checking, the options <samp><span class="option">-Wformat-y2k</span></samp>,
312<samp><span class="option">-Wno-format-extra-args</span></samp>, <samp><span class="option">-Wno-format-zero-length</span></samp>,
313<samp><span class="option">-Wformat-nonliteral</span></samp>, <samp><span class="option">-Wformat-security</span></samp>, and
314<samp><span class="option">-Wformat=2</span></samp> are available, but are not included in <samp><span class="option">-Wall</span></samp>.
315
316     <br><dt><code>-Wformat-y2k</code><dd><a name="index-Wformat_002dy2k-261"></a><a name="index-Wno_002dformat_002dy2k-262"></a>If <samp><span class="option">-Wformat</span></samp> is specified, also warn about <code>strftime</code>
317formats which may yield only a two-digit year.
318
319     <br><dt><code>-Wno-format-contains-nul</code><dd><a name="index-Wno_002dformat_002dcontains_002dnul-263"></a><a name="index-Wformat_002dcontains_002dnul-264"></a>If <samp><span class="option">-Wformat</span></samp> is specified, do not warn about format strings that
320contain NUL bytes.
321
322     <br><dt><code>-Wno-format-extra-args</code><dd><a name="index-Wno_002dformat_002dextra_002dargs-265"></a><a name="index-Wformat_002dextra_002dargs-266"></a>If <samp><span class="option">-Wformat</span></samp> is specified, do not warn about excess arguments to a
323<code>printf</code> or <code>scanf</code> format function.  The C standard specifies
324that such arguments are ignored.
325
326     <p>Where the unused arguments lie between used arguments that are
327specified with &lsquo;<samp><span class="samp">$</span></samp>&rsquo; operand number specifications, normally
328warnings are still given, since the implementation could not know what
329type to pass to <code>va_arg</code> to skip the unused arguments.  However,
330in the case of <code>scanf</code> formats, this option will suppress the
331warning if the unused arguments are all pointers, since the Single
332Unix Specification says that such unused arguments are allowed.
333
334     <br><dt><code>-Wno-format-zero-length </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wno_002dformat_002dzero_002dlength-267"></a><a name="index-Wformat_002dzero_002dlength-268"></a>If <samp><span class="option">-Wformat</span></samp> is specified, do not warn about zero-length formats. 
335The C standard specifies that zero-length formats are allowed.
336
337     <br><dt><code>-Wformat-nonliteral</code><dd><a name="index-Wformat_002dnonliteral-269"></a><a name="index-Wno_002dformat_002dnonliteral-270"></a>If <samp><span class="option">-Wformat</span></samp> is specified, also warn if the format string is not a
338string literal and so cannot be checked, unless the format function
339takes its format arguments as a <code>va_list</code>.
340
341     <br><dt><code>-Wformat-security</code><dd><a name="index-Wformat_002dsecurity-271"></a><a name="index-Wno_002dformat_002dsecurity-272"></a>If <samp><span class="option">-Wformat</span></samp> is specified, also warn about uses of format
342functions that represent possible security problems.  At present, this
343warns about calls to <code>printf</code> and <code>scanf</code> functions where the
344format string is not a string literal and there are no format arguments,
345as in <code>printf (foo);</code>.  This may be a security hole if the format
346string came from untrusted input and contains &lsquo;<samp><span class="samp">%n</span></samp>&rsquo;.  (This is
347currently a subset of what <samp><span class="option">-Wformat-nonliteral</span></samp> warns about, but
348in future warnings may be added to <samp><span class="option">-Wformat-security</span></samp> that are not
349included in <samp><span class="option">-Wformat-nonliteral</span></samp>.)
350
351     <br><dt><code>-Wformat=2</code><dd><a name="index-Wformat_003d2-273"></a><a name="index-Wno_002dformat_003d2-274"></a>Enable <samp><span class="option">-Wformat</span></samp> plus format checks not included in
352<samp><span class="option">-Wformat</span></samp>.  Currently equivalent to &lsquo;<samp><span class="samp">-Wformat
353-Wformat-nonliteral -Wformat-security -Wformat-y2k</span></samp>&rsquo;.
354
355     <br><dt><code>-Wnonnull </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wnonnull-275"></a><a name="index-Wno_002dnonnull-276"></a>Warn about passing a null pointer for arguments marked as
356requiring a non-null value by the <code>nonnull</code> function attribute.
357
358     <p><samp><span class="option">-Wnonnull</span></samp> is included in <samp><span class="option">-Wall</span></samp> and <samp><span class="option">-Wformat</span></samp>.  It
359can be disabled with the <samp><span class="option">-Wno-nonnull</span></samp> option.
360
361     <br><dt><code>-Winit-self </code><span class="roman">(C, C++, Objective-C and Objective-C++ only)</span><dd><a name="index-Winit_002dself-277"></a><a name="index-Wno_002dinit_002dself-278"></a>Warn about uninitialized variables which are initialized with themselves. 
362Note this option can only be used with the <samp><span class="option">-Wuninitialized</span></samp> option.
363
364     <p>For example, GCC will warn about <code>i</code> being uninitialized in the
365following snippet only when <samp><span class="option">-Winit-self</span></samp> has been specified:
366     <pre class="smallexample">          int f()
367          {
368            int i = i;
369            return i;
370          }
371</pre>
372     <br><dt><code>-Wimplicit-int </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wimplicit_002dint-279"></a><a name="index-Wno_002dimplicit_002dint-280"></a>Warn when a declaration does not specify a type. 
373This warning is enabled by <samp><span class="option">-Wall</span></samp>.
374
375     <br><dt><code>-Wimplicit-function-declaration </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wimplicit_002dfunction_002ddeclaration-281"></a><a name="index-Wno_002dimplicit_002dfunction_002ddeclaration-282"></a>Give a warning whenever a function is used before being declared. In
376C99 mode (<samp><span class="option">-std=c99</span></samp> or <samp><span class="option">-std=gnu99</span></samp>), this warning is
377enabled by default and it is made into an error by
378<samp><span class="option">-pedantic-errors</span></samp>. This warning is also enabled by
379<samp><span class="option">-Wall</span></samp>.
380
381     <br><dt><code>-Wimplicit </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wimplicit-283"></a><a name="index-Wno_002dimplicit-284"></a>Same as <samp><span class="option">-Wimplicit-int</span></samp> and <samp><span class="option">-Wimplicit-function-declaration</span></samp>. 
382This warning is enabled by <samp><span class="option">-Wall</span></samp>.
383
384     <br><dt><code>-Wignored-qualifiers </code><span class="roman">(C and C++ only)</span><dd><a name="index-Wignored_002dqualifiers-285"></a><a name="index-Wno_002dignored_002dqualifiers-286"></a>Warn if the return type of a function has a type qualifier
385such as <code>const</code>.  For ISO C such a type qualifier has no effect,
386since the value returned by a function is not an lvalue. 
387For C++, the warning is only emitted for scalar types or <code>void</code>. 
388ISO C prohibits qualified <code>void</code> return types on function
389definitions, so such return types always receive a warning
390even without this option.
391
392     <p>This warning is also enabled by <samp><span class="option">-Wextra</span></samp>.
393
394     <br><dt><code>-Wmain</code><dd><a name="index-Wmain-287"></a><a name="index-Wno_002dmain-288"></a>Warn if the type of &lsquo;<samp><span class="samp">main</span></samp>&rsquo; is suspicious.  &lsquo;<samp><span class="samp">main</span></samp>&rsquo; should be
395a function with external linkage, returning int, taking either zero
396arguments, two, or three arguments of appropriate types.  This warning
397is enabled by default in C++ and is enabled by either <samp><span class="option">-Wall</span></samp>
398or <samp><span class="option">-pedantic</span></samp>.
399
400     <br><dt><code>-Wmissing-braces</code><dd><a name="index-Wmissing_002dbraces-289"></a><a name="index-Wno_002dmissing_002dbraces-290"></a>Warn if an aggregate or union initializer is not fully bracketed.  In
401the following example, the initializer for &lsquo;<samp><span class="samp">a</span></samp>&rsquo; is not fully
402bracketed, but that for &lsquo;<samp><span class="samp">b</span></samp>&rsquo; is fully bracketed.
403
404     <pre class="smallexample">          int a[2][2] = { 0, 1, 2, 3 };
405          int b[2][2] = { { 0, 1 }, { 2, 3 } };
406</pre>
407     <p>This warning is enabled by <samp><span class="option">-Wall</span></samp>.
408
409     <br><dt><code>-Wmissing-include-dirs </code><span class="roman">(C, C++, Objective-C and Objective-C++ only)</span><dd><a name="index-Wmissing_002dinclude_002ddirs-291"></a><a name="index-Wno_002dmissing_002dinclude_002ddirs-292"></a>Warn if a user-supplied include directory does not exist.
410
411     <br><dt><code>-Wparentheses</code><dd><a name="index-Wparentheses-293"></a><a name="index-Wno_002dparentheses-294"></a>Warn if parentheses are omitted in certain contexts, such
412as when there is an assignment in a context where a truth value
413is expected, or when operators are nested whose precedence people
414often get confused about.
415
416     <p>Also warn if a comparison like &lsquo;<samp><span class="samp">x&lt;=y&lt;=z</span></samp>&rsquo; appears; this is
417equivalent to &lsquo;<samp><span class="samp">(x&lt;=y ? 1 : 0) &lt;= z</span></samp>&rsquo;, which is a different
418interpretation from that of ordinary mathematical notation.
419
420     <p>Also warn about constructions where there may be confusion to which
421<code>if</code> statement an <code>else</code> branch belongs.  Here is an example of
422such a case:
423
424     <pre class="smallexample">          {
425            if (a)
426              if (b)
427                foo ();
428            else
429              bar ();
430          }
431</pre>
432     <p>In C/C++, every <code>else</code> branch belongs to the innermost possible
433<code>if</code> statement, which in this example is <code>if (b)</code>.  This is
434often not what the programmer expected, as illustrated in the above
435example by indentation the programmer chose.  When there is the
436potential for this confusion, GCC will issue a warning when this flag
437is specified.  To eliminate the warning, add explicit braces around
438the innermost <code>if</code> statement so there is no way the <code>else</code>
439could belong to the enclosing <code>if</code>.  The resulting code would
440look like this:
441
442     <pre class="smallexample">          {
443            if (a)
444              {
445                if (b)
446                  foo ();
447                else
448                  bar ();
449              }
450          }
451</pre>
452     <p>Also warn for dangerous uses of the
453?: with omitted middle operand GNU extension. When the condition
454in the ?: operator is a boolean expression the omitted value will
455be always 1. Often the user expects it to be a value computed
456inside the conditional expression instead.
457
458     <p>This warning is enabled by <samp><span class="option">-Wall</span></samp>.
459
460     <br><dt><code>-Wsequence-point</code><dd><a name="index-Wsequence_002dpoint-295"></a><a name="index-Wno_002dsequence_002dpoint-296"></a>Warn about code that may have undefined semantics because of violations
461of sequence point rules in the C and C++ standards.
462
463     <p>The C and C++ standards defines the order in which expressions in a C/C++
464program are evaluated in terms of <dfn>sequence points</dfn>, which represent
465a partial ordering between the execution of parts of the program: those
466executed before the sequence point, and those executed after it.  These
467occur after the evaluation of a full expression (one which is not part
468of a larger expression), after the evaluation of the first operand of a
469<code>&amp;&amp;</code>, <code>||</code>, <code>? :</code> or <code>,</code> (comma) operator, before a
470function is called (but after the evaluation of its arguments and the
471expression denoting the called function), and in certain other places. 
472Other than as expressed by the sequence point rules, the order of
473evaluation of subexpressions of an expression is not specified.  All
474these rules describe only a partial order rather than a total order,
475since, for example, if two functions are called within one expression
476with no sequence point between them, the order in which the functions
477are called is not specified.  However, the standards committee have
478ruled that function calls do not overlap.
479
480     <p>It is not specified when between sequence points modifications to the
481values of objects take effect.  Programs whose behavior depends on this
482have undefined behavior; the C and C++ standards specify that &ldquo;Between
483the previous and next sequence point an object shall have its stored
484value modified at most once by the evaluation of an expression. 
485Furthermore, the prior value shall be read only to determine the value
486to be stored.&rdquo;.  If a program breaks these rules, the results on any
487particular implementation are entirely unpredictable.
488
489     <p>Examples of code with undefined behavior are <code>a = a++;</code>, <code>a[n]
490= b[n++]</code> and <code>a[i++] = i;</code>.  Some more complicated cases are not
491diagnosed by this option, and it may give an occasional false positive
492result, but in general it has been found fairly effective at detecting
493this sort of problem in programs.
494
495     <p>The standard is worded confusingly, therefore there is some debate
496over the precise meaning of the sequence point rules in subtle cases. 
497Links to discussions of the problem, including proposed formal
498definitions, may be found on the GCC readings page, at
499<a href="http://gcc.gnu.org/readings.html">http://gcc.gnu.org/readings.html</a>.
500
501     <p>This warning is enabled by <samp><span class="option">-Wall</span></samp> for C and C++.
502
503     <br><dt><code>-Wreturn-type</code><dd><a name="index-Wreturn_002dtype-297"></a><a name="index-Wno_002dreturn_002dtype-298"></a>Warn whenever a function is defined with a return-type that defaults
504to <code>int</code>.  Also warn about any <code>return</code> statement with no
505return-value in a function whose return-type is not <code>void</code>
506(falling off the end of the function body is considered returning
507without a value), and about a <code>return</code> statement with an
508expression in a function whose return-type is <code>void</code>.
509
510     <p>For C++, a function without return type always produces a diagnostic
511message, even when <samp><span class="option">-Wno-return-type</span></samp> is specified.  The only
512exceptions are &lsquo;<samp><span class="samp">main</span></samp>&rsquo; and functions defined in system headers.
513
514     <p>This warning is enabled by <samp><span class="option">-Wall</span></samp>.
515
516     <br><dt><code>-Wswitch</code><dd><a name="index-Wswitch-299"></a><a name="index-Wno_002dswitch-300"></a>Warn whenever a <code>switch</code> statement has an index of enumerated type
517and lacks a <code>case</code> for one or more of the named codes of that
518enumeration.  (The presence of a <code>default</code> label prevents this
519warning.)  <code>case</code> labels outside the enumeration range also
520provoke warnings when this option is used (even if there is a
521<code>default</code> label). 
522This warning is enabled by <samp><span class="option">-Wall</span></samp>.
523
524     <br><dt><code>-Wswitch-default</code><dd><a name="index-Wswitch_002ddefault-301"></a><a name="index-Wno_002dswitch_002ddefault-302"></a>Warn whenever a <code>switch</code> statement does not have a <code>default</code>
525case.
526
527     <br><dt><code>-Wswitch-enum</code><dd><a name="index-Wswitch_002denum-303"></a><a name="index-Wno_002dswitch_002denum-304"></a>Warn whenever a <code>switch</code> statement has an index of enumerated type
528and lacks a <code>case</code> for one or more of the named codes of that
529enumeration.  <code>case</code> labels outside the enumeration range also
530provoke warnings when this option is used.  The only difference
531between <samp><span class="option">-Wswitch</span></samp> and this option is that this option gives a
532warning about an omitted enumeration code even if there is a
533<code>default</code> label.
534
535     <br><dt><code>-Wsync-nand </code><span class="roman">(C and C++ only)</span><dd><a name="index-Wsync_002dnand-305"></a><a name="index-Wno_002dsync_002dnand-306"></a>Warn when <code>__sync_fetch_and_nand</code> and <code>__sync_nand_and_fetch</code>
536built-in functions are used.  These functions changed semantics in GCC 4.4.
537
538     <br><dt><code>-Wtrigraphs</code><dd><a name="index-Wtrigraphs-307"></a><a name="index-Wno_002dtrigraphs-308"></a>Warn if any trigraphs are encountered that might change the meaning of
539the program (trigraphs within comments are not warned about). 
540This warning is enabled by <samp><span class="option">-Wall</span></samp>.
541
542     <br><dt><code>-Wunused-but-set-parameter</code><dd><a name="index-Wunused_002dbut_002dset_002dparameter-309"></a><a name="index-Wno_002dunused_002dbut_002dset_002dparameter-310"></a>Warn whenever a function parameter is assigned to, but otherwise unused
543(aside from its declaration).
544
545     <p>To suppress this warning use the &lsquo;<samp><span class="samp">unused</span></samp>&rsquo; attribute
546(see <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>).
547
548     <p>This warning is also enabled by <samp><span class="option">-Wunused</span></samp> together with
549<samp><span class="option">-Wextra</span></samp>.
550
551     <br><dt><code>-Wunused-but-set-variable</code><dd><a name="index-Wunused_002dbut_002dset_002dvariable-311"></a><a name="index-Wno_002dunused_002dbut_002dset_002dvariable-312"></a>Warn whenever a local variable is assigned to, but otherwise unused
552(aside from its declaration). 
553This warning is enabled by <samp><span class="option">-Wall</span></samp>.
554
555     <p>To suppress this warning use the &lsquo;<samp><span class="samp">unused</span></samp>&rsquo; attribute
556(see <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>).
557
558     <p>This warning is also enabled by <samp><span class="option">-Wunused</span></samp>, which is enabled
559by <samp><span class="option">-Wall</span></samp>.
560
561     <br><dt><code>-Wunused-function</code><dd><a name="index-Wunused_002dfunction-313"></a><a name="index-Wno_002dunused_002dfunction-314"></a>Warn whenever a static function is declared but not defined or a
562non-inline static function is unused. 
563This warning is enabled by <samp><span class="option">-Wall</span></samp>.
564
565     <br><dt><code>-Wunused-label</code><dd><a name="index-Wunused_002dlabel-315"></a><a name="index-Wno_002dunused_002dlabel-316"></a>Warn whenever a label is declared but not used. 
566This warning is enabled by <samp><span class="option">-Wall</span></samp>.
567
568     <p>To suppress this warning use the &lsquo;<samp><span class="samp">unused</span></samp>&rsquo; attribute
569(see <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>).
570
571     <br><dt><code>-Wunused-parameter</code><dd><a name="index-Wunused_002dparameter-317"></a><a name="index-Wno_002dunused_002dparameter-318"></a>Warn whenever a function parameter is unused aside from its declaration.
572
573     <p>To suppress this warning use the &lsquo;<samp><span class="samp">unused</span></samp>&rsquo; attribute
574(see <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>).
575
576     <br><dt><code>-Wno-unused-result</code><dd><a name="index-Wunused_002dresult-319"></a><a name="index-Wno_002dunused_002dresult-320"></a>Do not warn if a caller of a function marked with attribute
577<code>warn_unused_result</code> (see <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>) does not use
578its return value. The default is <samp><span class="option">-Wunused-result</span></samp>.
579
580     <br><dt><code>-Wunused-variable</code><dd><a name="index-Wunused_002dvariable-321"></a><a name="index-Wno_002dunused_002dvariable-322"></a>Warn whenever a local variable or non-constant static variable is unused
581aside from its declaration. 
582This warning is enabled by <samp><span class="option">-Wall</span></samp>.
583
584     <p>To suppress this warning use the &lsquo;<samp><span class="samp">unused</span></samp>&rsquo; attribute
585(see <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>).
586
587     <br><dt><code>-Wunused-value</code><dd><a name="index-Wunused_002dvalue-323"></a><a name="index-Wno_002dunused_002dvalue-324"></a>Warn whenever a statement computes a result that is explicitly not
588used. To suppress this warning cast the unused expression to
589&lsquo;<samp><span class="samp">void</span></samp>&rsquo;. This includes an expression-statement or the left-hand
590side of a comma expression that contains no side effects. For example,
591an expression such as &lsquo;<samp><span class="samp">x[i,j]</span></samp>&rsquo; will cause a warning, while
592&lsquo;<samp><span class="samp">x[(void)i,j]</span></samp>&rsquo; will not.
593
594     <p>This warning is enabled by <samp><span class="option">-Wall</span></samp>.
595
596     <br><dt><code>-Wunused</code><dd><a name="index-Wunused-325"></a><a name="index-Wno_002dunused-326"></a>All the above <samp><span class="option">-Wunused</span></samp> options combined.
597
598     <p>In order to get a warning about an unused function parameter, you must
599either specify &lsquo;<samp><span class="samp">-Wextra -Wunused</span></samp>&rsquo; (note that &lsquo;<samp><span class="samp">-Wall</span></samp>&rsquo; implies
600&lsquo;<samp><span class="samp">-Wunused</span></samp>&rsquo;), or separately specify <samp><span class="option">-Wunused-parameter</span></samp>.
601
602     <br><dt><code>-Wuninitialized</code><dd><a name="index-Wuninitialized-327"></a><a name="index-Wno_002duninitialized-328"></a>Warn if an automatic variable is used without first being initialized
603or if a variable may be clobbered by a <code>setjmp</code> call. In C++,
604warn if a non-static reference or non-static &lsquo;<samp><span class="samp">const</span></samp>&rsquo; member
605appears in a class without constructors.
606
607     <p>If you want to warn about code which uses the uninitialized value of the
608variable in its own initializer, use the <samp><span class="option">-Winit-self</span></samp> option.
609
610     <p>These warnings occur for individual uninitialized or clobbered
611elements of structure, union or array variables as well as for
612variables which are uninitialized or clobbered as a whole.  They do
613not occur for variables or elements declared <code>volatile</code>.  Because
614these warnings depend on optimization, the exact variables or elements
615for which there are warnings will depend on the precise optimization
616options and version of GCC used.
617
618     <p>Note that there may be no warning about a variable that is used only
619to compute a value that itself is never used, because such
620computations may be deleted by data flow analysis before the warnings
621are printed.
622
623     <p>These warnings are made optional because GCC is not smart
624enough to see all the reasons why the code might be correct
625despite appearing to have an error.  Here is one example of how
626this can happen:
627
628     <pre class="smallexample">          {
629            int x;
630            switch (y)
631              {
632              case 1: x = 1;
633                break;
634              case 2: x = 4;
635                break;
636              case 3: x = 5;
637              }
638            foo (x);
639          }
640</pre>
641     <p class="noindent">If the value of <code>y</code> is always 1, 2 or 3, then <code>x</code> is
642always initialized, but GCC doesn't know this.  Here is
643another common case:
644
645     <pre class="smallexample">          {
646            int save_y;
647            if (change_y) save_y = y, y = new_y;
648            ...
649            if (change_y) y = save_y;
650          }
651</pre>
652     <p class="noindent">This has no bug because <code>save_y</code> is used only if it is set.
653
654     <p><a name="index-g_t_0040code_007blongjmp_007d-warnings-329"></a>This option also warns when a non-volatile automatic variable might be
655changed by a call to <code>longjmp</code>.  These warnings as well are possible
656only in optimizing compilation.
657
658     <p>The compiler sees only the calls to <code>setjmp</code>.  It cannot know
659where <code>longjmp</code> will be called; in fact, a signal handler could
660call it at any point in the code.  As a result, you may get a warning
661even when there is in fact no problem because <code>longjmp</code> cannot
662in fact be called at the place which would cause a problem.
663
664     <p>Some spurious warnings can be avoided if you declare all the functions
665you use that never return as <code>noreturn</code>.  See <a href="Function-Attributes.html#Function-Attributes">Function Attributes</a>.
666
667     <p>This warning is enabled by <samp><span class="option">-Wall</span></samp> or <samp><span class="option">-Wextra</span></samp>.
668
669     <br><dt><code>-Wunknown-pragmas</code><dd><a name="index-Wunknown_002dpragmas-330"></a><a name="index-Wno_002dunknown_002dpragmas-331"></a><a name="index-warning-for-unknown-pragmas-332"></a><a name="index-unknown-pragmas_002c-warning-333"></a><a name="index-pragmas_002c-warning-of-unknown-334"></a>Warn when a #pragma directive is encountered which is not understood by
670GCC.  If this command line option is used, warnings will even be issued
671for unknown pragmas in system header files.  This is not the case if
672the warnings were only enabled by the <samp><span class="option">-Wall</span></samp> command line option.
673
674     <br><dt><code>-Wno-pragmas</code><dd><a name="index-Wno_002dpragmas-335"></a><a name="index-Wpragmas-336"></a>Do not warn about misuses of pragmas, such as incorrect parameters,
675invalid syntax, or conflicts between pragmas.  See also
676&lsquo;<samp><span class="samp">-Wunknown-pragmas</span></samp>&rsquo;.
677
678     <br><dt><code>-Wstrict-aliasing</code><dd><a name="index-Wstrict_002daliasing-337"></a><a name="index-Wno_002dstrict_002daliasing-338"></a>This option is only active when <samp><span class="option">-fstrict-aliasing</span></samp> is active. 
679It warns about code which might break the strict aliasing rules that the
680compiler is using for optimization.  The warning does not catch all
681cases, but does attempt to catch the more common pitfalls.  It is
682included in <samp><span class="option">-Wall</span></samp>. 
683It is equivalent to <samp><span class="option">-Wstrict-aliasing=3</span></samp>
684
685     <br><dt><code>-Wstrict-aliasing=n</code><dd><a name="index-Wstrict_002daliasing_003dn-339"></a><a name="index-Wno_002dstrict_002daliasing_003dn-340"></a>This option is only active when <samp><span class="option">-fstrict-aliasing</span></samp> is active. 
686It warns about code which might break the strict aliasing rules that the
687compiler is using for optimization. 
688Higher levels correspond to higher accuracy (fewer false positives). 
689Higher levels also correspond to more effort, similar to the way -O works. 
690<samp><span class="option">-Wstrict-aliasing</span></samp> is equivalent to <samp><span class="option">-Wstrict-aliasing=n</span></samp>,
691with n=3.
692
693     <p>Level 1: Most aggressive, quick, least accurate. 
694Possibly useful when higher levels
695do not warn but -fstrict-aliasing still breaks the code, as it has very few
696false negatives.  However, it has many false positives. 
697Warns for all pointer conversions between possibly incompatible types,
698even if never dereferenced.  Runs in the frontend only.
699
700     <p>Level 2: Aggressive, quick, not too precise. 
701May still have many false positives (not as many as level 1 though),
702and few false negatives (but possibly more than level 1). 
703Unlike level 1, it only warns when an address is taken.  Warns about
704incomplete types.  Runs in the frontend only.
705
706     <p>Level 3 (default for <samp><span class="option">-Wstrict-aliasing</span></samp>):
707Should have very few false positives and few false
708negatives.  Slightly slower than levels 1 or 2 when optimization is enabled. 
709Takes care of the common pun+dereference pattern in the frontend:
710<code>*(int*)&amp;some_float</code>. 
711If optimization is enabled, it also runs in the backend, where it deals
712with multiple statement cases using flow-sensitive points-to information. 
713Only warns when the converted pointer is dereferenced. 
714Does not warn about incomplete types.
715
716     <br><dt><code>-Wstrict-overflow</code><dt><code>-Wstrict-overflow=</code><var>n</var><dd><a name="index-Wstrict_002doverflow-341"></a><a name="index-Wno_002dstrict_002doverflow-342"></a>This option is only active when <samp><span class="option">-fstrict-overflow</span></samp> is active. 
717It warns about cases where the compiler optimizes based on the
718assumption that signed overflow does not occur.  Note that it does not
719warn about all cases where the code might overflow: it only warns
720about cases where the compiler implements some optimization.  Thus
721this warning depends on the optimization level.
722
723     <p>An optimization which assumes that signed overflow does not occur is
724perfectly safe if the values of the variables involved are such that
725overflow never does, in fact, occur.  Therefore this warning can
726easily give a false positive: a warning about code which is not
727actually a problem.  To help focus on important issues, several
728warning levels are defined.  No warnings are issued for the use of
729undefined signed overflow when estimating how many iterations a loop
730will require, in particular when determining whether a loop will be
731executed at all.
732
733          <dl>
734<dt><code>-Wstrict-overflow=1</code><dd>Warn about cases which are both questionable and easy to avoid.  For
735example: <code>x + 1 &gt; x</code>; with <samp><span class="option">-fstrict-overflow</span></samp>, the
736compiler will simplify this to <code>1</code>.  This level of
737<samp><span class="option">-Wstrict-overflow</span></samp> is enabled by <samp><span class="option">-Wall</span></samp>; higher levels
738are not, and must be explicitly requested.
739
740          <br><dt><code>-Wstrict-overflow=2</code><dd>Also warn about other cases where a comparison is simplified to a
741constant.  For example: <code>abs (x) &gt;= 0</code>.  This can only be
742simplified when <samp><span class="option">-fstrict-overflow</span></samp> is in effect, because
743<code>abs (INT_MIN)</code> overflows to <code>INT_MIN</code>, which is less than
744zero.  <samp><span class="option">-Wstrict-overflow</span></samp> (with no level) is the same as
745<samp><span class="option">-Wstrict-overflow=2</span></samp>.
746
747          <br><dt><code>-Wstrict-overflow=3</code><dd>Also warn about other cases where a comparison is simplified.  For
748example: <code>x + 1 &gt; 1</code> will be simplified to <code>x &gt; 0</code>.
749
750          <br><dt><code>-Wstrict-overflow=4</code><dd>Also warn about other simplifications not covered by the above cases. 
751For example: <code>(x * 10) / 5</code> will be simplified to <code>x * 2</code>.
752
753          <br><dt><code>-Wstrict-overflow=5</code><dd>Also warn about cases where the compiler reduces the magnitude of a
754constant involved in a comparison.  For example: <code>x + 2 &gt; y</code> will
755be simplified to <code>x + 1 &gt;= y</code>.  This is reported only at the
756highest warning level because this simplification applies to many
757comparisons, so this warning level will give a very large number of
758false positives. 
759</dl>
760
761     <br><dt><code>-Wsuggest-attribute=</code><span class="roman">[</span><code>pure</code><span class="roman">|</span><code>const</code><span class="roman">|</span><code>noreturn</code><span class="roman">]</span><dd><a name="index-Wsuggest_002dattribute_003d-343"></a><a name="index-Wno_002dsuggest_002dattribute_003d-344"></a>Warn for cases where adding an attribute may be beneficial. The
762attributes currently supported are listed below.
763
764          <dl>
765<dt><code>-Wsuggest-attribute=pure</code><dt><code>-Wsuggest-attribute=const</code><dt><code>-Wsuggest-attribute=noreturn</code><dd><a name="index-Wsuggest_002dattribute_003dpure-345"></a><a name="index-Wno_002dsuggest_002dattribute_003dpure-346"></a><a name="index-Wsuggest_002dattribute_003dconst-347"></a><a name="index-Wno_002dsuggest_002dattribute_003dconst-348"></a><a name="index-Wsuggest_002dattribute_003dnoreturn-349"></a><a name="index-Wno_002dsuggest_002dattribute_003dnoreturn-350"></a>
766Warn about functions which might be candidates for attributes
767<code>pure</code>, <code>const</code> or <code>noreturn</code>.  The compiler only warns for
768functions visible in other compilation units or (in the case of <code>pure</code> and
769<code>const</code>) if it cannot prove that the function returns normally. A function
770returns normally if it doesn't contain an infinite loop nor returns abnormally
771by throwing, calling <code>abort()</code> or trapping.  This analysis requires option
772<samp><span class="option">-fipa-pure-const</span></samp>, which is enabled by default at <samp><span class="option">-O</span></samp> and
773higher.  Higher optimization levels improve the accuracy of the analysis. 
774</dl>
775
776     <br><dt><code>-Warray-bounds</code><dd><a name="index-Wno_002darray_002dbounds-351"></a><a name="index-Warray_002dbounds-352"></a>This option is only active when <samp><span class="option">-ftree-vrp</span></samp> is active
777(default for <samp><span class="option">-O2</span></samp> and above). It warns about subscripts to arrays
778that are always out of bounds. This warning is enabled by <samp><span class="option">-Wall</span></samp>.
779
780     <br><dt><code>-Wno-div-by-zero</code><dd><a name="index-Wno_002ddiv_002dby_002dzero-353"></a><a name="index-Wdiv_002dby_002dzero-354"></a>Do not warn about compile-time integer division by zero.  Floating point
781division by zero is not warned about, as it can be a legitimate way of
782obtaining infinities and NaNs.
783
784     <br><dt><code>-Wsystem-headers</code><dd><a name="index-Wsystem_002dheaders-355"></a><a name="index-Wno_002dsystem_002dheaders-356"></a><a name="index-warnings-from-system-headers-357"></a><a name="index-system-headers_002c-warnings-from-358"></a>Print warning messages for constructs found in system header files. 
785Warnings from system headers are normally suppressed, on the assumption
786that they usually do not indicate real problems and would only make the
787compiler output harder to read.  Using this command line option tells
788GCC to emit warnings from system headers as if they occurred in user
789code.  However, note that using <samp><span class="option">-Wall</span></samp> in conjunction with this
790option will <em>not</em> warn about unknown pragmas in system
791headers&mdash;for that, <samp><span class="option">-Wunknown-pragmas</span></samp> must also be used.
792
793     <br><dt><code>-Wtrampolines</code><dd><a name="index-Wtrampolines-359"></a><a name="index-Wno_002dtrampolines-360"></a> Warn about trampolines generated for pointers to nested functions.
794
795     <p>A trampoline is a small piece of data or code that is created at run
796 time on the stack when the address of a nested function is taken, and
797 is used to call the nested function indirectly.  For some targets, it
798 is made up of data only and thus requires no special treatment.  But,
799 for most targets, it is made up of code and thus requires the stack
800 to be made executable in order for the program to work properly.
801
802     <br><dt><code>-Wno-poison-system-directories</code><dd><a name="index-Wno_002dpoison_002dsystem_002ddirectories-361"></a>Do not warn for <samp><span class="option">-I</span></samp> or <samp><span class="option">-L</span></samp> options using system
803directories such as <samp><span class="file">/usr/include</span></samp> when cross compiling.  This
804option is intended for use in chroot environments when such
805directories contain the correct headers and libraries for the target
806system rather than the host.
807
808     <br><dt><code>-Wfloat-equal</code><dd><a name="index-Wfloat_002dequal-362"></a><a name="index-Wno_002dfloat_002dequal-363"></a>Warn if floating point values are used in equality comparisons.
809
810     <p>The idea behind this is that sometimes it is convenient (for the
811programmer) to consider floating-point values as approximations to
812infinitely precise real numbers.  If you are doing this, then you need
813to compute (by analyzing the code, or in some other way) the maximum or
814likely maximum error that the computation introduces, and allow for it
815when performing comparisons (and when producing output, but that's a
816different problem).  In particular, instead of testing for equality, you
817would check to see whether the two values have ranges that overlap; and
818this is done with the relational operators, so equality comparisons are
819probably mistaken.
820
821     <br><dt><code>-Wtraditional </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wtraditional-364"></a><a name="index-Wno_002dtraditional-365"></a>Warn about certain constructs that behave differently in traditional and
822ISO C.  Also warn about ISO C constructs that have no traditional C
823equivalent, and/or problematic constructs which should be avoided.
824
825          <ul>
826<li>Macro parameters that appear within string literals in the macro body. 
827In traditional C macro replacement takes place within string literals,
828but does not in ISO C.
829
830          <li>In traditional C, some preprocessor directives did not exist. 
831Traditional preprocessors would only consider a line to be a directive
832if the &lsquo;<samp><span class="samp">#</span></samp>&rsquo; appeared in column 1 on the line.  Therefore
833<samp><span class="option">-Wtraditional</span></samp> warns about directives that traditional C
834understands but would ignore because the &lsquo;<samp><span class="samp">#</span></samp>&rsquo; does not appear as the
835first character on the line.  It also suggests you hide directives like
836&lsquo;<samp><span class="samp">#pragma</span></samp>&rsquo; not understood by traditional C by indenting them.  Some
837traditional implementations would not recognize &lsquo;<samp><span class="samp">#elif</span></samp>&rsquo;, so it
838suggests avoiding it altogether.
839
840          <li>A function-like macro that appears without arguments.
841
842          <li>The unary plus operator.
843
844          <li>The &lsquo;<samp><span class="samp">U</span></samp>&rsquo; integer constant suffix, or the &lsquo;<samp><span class="samp">F</span></samp>&rsquo; or &lsquo;<samp><span class="samp">L</span></samp>&rsquo; floating point
845constant suffixes.  (Traditional C does support the &lsquo;<samp><span class="samp">L</span></samp>&rsquo; suffix on integer
846constants.)  Note, these suffixes appear in macros defined in the system
847headers of most modern systems, e.g. the &lsquo;<samp><span class="samp">_MIN</span></samp>&rsquo;/&lsquo;<samp><span class="samp">_MAX</span></samp>&rsquo; macros in <code>&lt;limits.h&gt;</code>. 
848Use of these macros in user code might normally lead to spurious
849warnings, however GCC's integrated preprocessor has enough context to
850avoid warning in these cases.
851
852          <li>A function declared external in one block and then used after the end of
853the block.
854
855          <li>A <code>switch</code> statement has an operand of type <code>long</code>.
856
857          <li>A non-<code>static</code> function declaration follows a <code>static</code> one. 
858This construct is not accepted by some traditional C compilers.
859
860          <li>The ISO type of an integer constant has a different width or
861signedness from its traditional type.  This warning is only issued if
862the base of the constant is ten.  I.e. hexadecimal or octal values, which
863typically represent bit patterns, are not warned about.
864
865          <li>Usage of ISO string concatenation is detected.
866
867          <li>Initialization of automatic aggregates.
868
869          <li>Identifier conflicts with labels.  Traditional C lacks a separate
870namespace for labels.
871
872          <li>Initialization of unions.  If the initializer is zero, the warning is
873omitted.  This is done under the assumption that the zero initializer in
874user code appears conditioned on e.g. <code>__STDC__</code> to avoid missing
875initializer warnings and relies on default initialization to zero in the
876traditional C case.
877
878          <li>Conversions by prototypes between fixed/floating point values and vice
879versa.  The absence of these prototypes when compiling with traditional
880C would cause serious problems.  This is a subset of the possible
881conversion warnings, for the full set use <samp><span class="option">-Wtraditional-conversion</span></samp>.
882
883          <li>Use of ISO C style function definitions.  This warning intentionally is
884<em>not</em> issued for prototype declarations or variadic functions
885because these ISO C features will appear in your code when using
886libiberty's traditional C compatibility macros, <code>PARAMS</code> and
887<code>VPARAMS</code>.  This warning is also bypassed for nested functions
888because that feature is already a GCC extension and thus not relevant to
889traditional C compatibility. 
890</ul>
891
892     <br><dt><code>-Wtraditional-conversion </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wtraditional_002dconversion-366"></a><a name="index-Wno_002dtraditional_002dconversion-367"></a>Warn if a prototype causes a type conversion that is different from what
893would happen to the same argument in the absence of a prototype.  This
894includes conversions of fixed point to floating and vice versa, and
895conversions changing the width or signedness of a fixed point argument
896except when the same as the default promotion.
897
898     <br><dt><code>-Wdeclaration-after-statement </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wdeclaration_002dafter_002dstatement-368"></a><a name="index-Wno_002ddeclaration_002dafter_002dstatement-369"></a>Warn when a declaration is found after a statement in a block.  This
899construct, known from C++, was introduced with ISO C99 and is by default
900allowed in GCC.  It is not supported by ISO C90 and was not supported by
901GCC versions before GCC 3.0.  See <a href="Mixed-Declarations.html#Mixed-Declarations">Mixed Declarations</a>.
902
903     <br><dt><code>-Wundef</code><dd><a name="index-Wundef-370"></a><a name="index-Wno_002dundef-371"></a>Warn if an undefined identifier is evaluated in an &lsquo;<samp><span class="samp">#if</span></samp>&rsquo; directive.
904
905     <br><dt><code>-Wno-endif-labels</code><dd><a name="index-Wno_002dendif_002dlabels-372"></a><a name="index-Wendif_002dlabels-373"></a>Do not warn whenever an &lsquo;<samp><span class="samp">#else</span></samp>&rsquo; or an &lsquo;<samp><span class="samp">#endif</span></samp>&rsquo; are followed by text.
906
907     <br><dt><code>-Wshadow</code><dd><a name="index-Wshadow-374"></a><a name="index-Wno_002dshadow-375"></a>Warn whenever a local variable or type declaration shadows another variable,
908parameter, type, or class member (in C++), or whenever a built-in function
909is shadowed. Note that in C++, the compiler will not warn if a local variable
910shadows a struct/class/enum, but will warn if it shadows an explicit typedef.
911
912     <br><dt><code>-Wlarger-than=</code><var>len</var><dd><a name="index-Wlarger_002dthan_003d_0040var_007blen_007d-376"></a><a name="index-Wlarger_002dthan_002d_0040var_007blen_007d-377"></a>Warn whenever an object of larger than <var>len</var> bytes is defined.
913
914     <br><dt><code>-Wframe-larger-than=</code><var>len</var><dd><a name="index-Wframe_002dlarger_002dthan-378"></a>Warn if the size of a function frame is larger than <var>len</var> bytes. 
915The computation done to determine the stack frame size is approximate
916and not conservative. 
917The actual requirements may be somewhat greater than <var>len</var>
918even if you do not get a warning.  In addition, any space allocated
919via <code>alloca</code>, variable-length arrays, or related constructs
920is not included by the compiler when determining
921whether or not to issue a warning.
922
923     <br><dt><code>-Wunsafe-loop-optimizations</code><dd><a name="index-Wunsafe_002dloop_002doptimizations-379"></a><a name="index-Wno_002dunsafe_002dloop_002doptimizations-380"></a>Warn if the loop cannot be optimized because the compiler could not
924assume anything on the bounds of the loop indices.  With
925<samp><span class="option">-funsafe-loop-optimizations</span></samp> warn if the compiler made
926such assumptions.
927
928     <br><dt><code>-Wno-pedantic-ms-format </code><span class="roman">(MinGW targets only)</span><dd><a name="index-Wno_002dpedantic_002dms_002dformat-381"></a><a name="index-Wpedantic_002dms_002dformat-382"></a>Disables the warnings about non-ISO <code>printf</code> / <code>scanf</code> format
929width specifiers <code>I32</code>, <code>I64</code>, and <code>I</code> used on Windows targets
930depending on the MS runtime, when you are using the options <samp><span class="option">-Wformat</span></samp>
931and <samp><span class="option">-pedantic</span></samp> without gnu-extensions.
932
933     <br><dt><code>-Wpointer-arith</code><dd><a name="index-Wpointer_002darith-383"></a><a name="index-Wno_002dpointer_002darith-384"></a>Warn about anything that depends on the &ldquo;size of&rdquo; a function type or
934of <code>void</code>.  GNU C assigns these types a size of 1, for
935convenience in calculations with <code>void *</code> pointers and pointers
936to functions.  In C++, warn also when an arithmetic operation involves
937<code>NULL</code>.  This warning is also enabled by <samp><span class="option">-pedantic</span></samp>.
938
939     <br><dt><code>-Wtype-limits</code><dd><a name="index-Wtype_002dlimits-385"></a><a name="index-Wno_002dtype_002dlimits-386"></a>Warn if a comparison is always true or always false due to the limited
940range of the data type, but do not warn for constant expressions.  For
941example, warn if an unsigned variable is compared against zero with
942&lsquo;<samp><span class="samp">&lt;</span></samp>&rsquo; or &lsquo;<samp><span class="samp">&gt;=</span></samp>&rsquo;.  This warning is also enabled by
943<samp><span class="option">-Wextra</span></samp>.
944
945     <br><dt><code>-Wbad-function-cast </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wbad_002dfunction_002dcast-387"></a><a name="index-Wno_002dbad_002dfunction_002dcast-388"></a>Warn whenever a function call is cast to a non-matching type. 
946For example, warn if <code>int malloc()</code> is cast to <code>anything *</code>.
947
948     <br><dt><code>-Wc++-compat </code><span class="roman">(C and Objective-C only)</span><dd>Warn about ISO C constructs that are outside of the common subset of
949ISO C and ISO C++, e.g. request for implicit conversion from
950<code>void *</code> to a pointer to non-<code>void</code> type.
951
952     <br><dt><code>-Wc++0x-compat </code><span class="roman">(C++ and Objective-C++ only)</span><dd>Warn about C++ constructs whose meaning differs between ISO C++ 1998 and
953ISO C++ 200x, e.g., identifiers in ISO C++ 1998 that will become keywords
954in ISO C++ 200x.  This warning is enabled by <samp><span class="option">-Wall</span></samp>.
955
956     <br><dt><code>-Wcast-qual</code><dd><a name="index-Wcast_002dqual-389"></a><a name="index-Wno_002dcast_002dqual-390"></a>Warn whenever a pointer is cast so as to remove a type qualifier from
957the target type.  For example, warn if a <code>const char *</code> is cast
958to an ordinary <code>char *</code>.
959
960     <p>Also warn when making a cast which introduces a type qualifier in an
961unsafe way.  For example, casting <code>char **</code> to <code>const char **</code>
962is unsafe, as in this example:
963
964     <pre class="smallexample">            /* p is char ** value.  */
965            const char **q = (const char **) p;
966            /* Assignment of readonly string to const char * is OK.  */
967            *q = "string";
968            /* Now char** pointer points to read-only memory.  */
969            **p = 'b';
970</pre>
971     <br><dt><code>-Wcast-align</code><dd><a name="index-Wcast_002dalign-391"></a><a name="index-Wno_002dcast_002dalign-392"></a>Warn whenever a pointer is cast such that the required alignment of the
972target is increased.  For example, warn if a <code>char *</code> is cast to
973an <code>int *</code> on machines where integers can only be accessed at
974two- or four-byte boundaries.
975
976     <br><dt><code>-Wwrite-strings</code><dd><a name="index-Wwrite_002dstrings-393"></a><a name="index-Wno_002dwrite_002dstrings-394"></a>When compiling C, give string constants the type <code>const
977char[</code><var>length</var><code>]</code> so that copying the address of one into a
978non-<code>const</code> <code>char *</code> pointer will get a warning.  These
979warnings will help you find at compile time code that can try to write
980into a string constant, but only if you have been very careful about
981using <code>const</code> in declarations and prototypes.  Otherwise, it will
982just be a nuisance. This is why we did not make <samp><span class="option">-Wall</span></samp> request
983these warnings.
984
985     <p>When compiling C++, warn about the deprecated conversion from string
986literals to <code>char *</code>.  This warning is enabled by default for C++
987programs.
988
989     <br><dt><code>-Wclobbered</code><dd><a name="index-Wclobbered-395"></a><a name="index-Wno_002dclobbered-396"></a>Warn for variables that might be changed by &lsquo;<samp><span class="samp">longjmp</span></samp>&rsquo; or
990&lsquo;<samp><span class="samp">vfork</span></samp>&rsquo;.  This warning is also enabled by <samp><span class="option">-Wextra</span></samp>.
991
992     <br><dt><code>-Wconversion</code><dd><a name="index-Wconversion-397"></a><a name="index-Wno_002dconversion-398"></a>Warn for implicit conversions that may alter a value. This includes
993conversions between real and integer, like <code>abs (x)</code> when
994<code>x</code> is <code>double</code>; conversions between signed and unsigned,
995like <code>unsigned ui = -1</code>; and conversions to smaller types, like
996<code>sqrtf (M_PI)</code>. Do not warn for explicit casts like <code>abs
997((int) x)</code> and <code>ui = (unsigned) -1</code>, or if the value is not
998changed by the conversion like in <code>abs (2.0)</code>.  Warnings about
999conversions between signed and unsigned integers can be disabled by
1000using <samp><span class="option">-Wno-sign-conversion</span></samp>.
1001
1002     <p>For C++, also warn for confusing overload resolution for user-defined
1003conversions; and conversions that will never use a type conversion
1004operator: conversions to <code>void</code>, the same type, a base class or a
1005reference to them. Warnings about conversions between signed and
1006unsigned integers are disabled by default in C++ unless
1007<samp><span class="option">-Wsign-conversion</span></samp> is explicitly enabled.
1008
1009     <br><dt><code>-Wno-conversion-null </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wconversion_002dnull-399"></a><a name="index-Wno_002dconversion_002dnull-400"></a>Do not warn for conversions between <code>NULL</code> and non-pointer
1010types. <samp><span class="option">-Wconversion-null</span></samp> is enabled by default.
1011
1012     <br><dt><code>-Wempty-body</code><dd><a name="index-Wempty_002dbody-401"></a><a name="index-Wno_002dempty_002dbody-402"></a>Warn if an empty body occurs in an &lsquo;<samp><span class="samp">if</span></samp>&rsquo;, &lsquo;<samp><span class="samp">else</span></samp>&rsquo; or &lsquo;<samp><span class="samp">do
1013while</span></samp>&rsquo; statement.  This warning is also enabled by <samp><span class="option">-Wextra</span></samp>.
1014
1015     <br><dt><code>-Wenum-compare</code><dd><a name="index-Wenum_002dcompare-403"></a><a name="index-Wno_002denum_002dcompare-404"></a>Warn about a comparison between values of different enum types. In C++
1016this warning is enabled by default.  In C this warning is enabled by
1017<samp><span class="option">-Wall</span></samp>.
1018
1019     <br><dt><code>-Wjump-misses-init </code><span class="roman">(C, Objective-C only)</span><dd><a name="index-Wjump_002dmisses_002dinit-405"></a><a name="index-Wno_002djump_002dmisses_002dinit-406"></a>Warn if a <code>goto</code> statement or a <code>switch</code> statement jumps
1020forward across the initialization of a variable, or jumps backward to a
1021label after the variable has been initialized.  This only warns about
1022variables which are initialized when they are declared.  This warning is
1023only supported for C and Objective C; in C++ this sort of branch is an
1024error in any case.
1025
1026     <p><samp><span class="option">-Wjump-misses-init</span></samp> is included in <samp><span class="option">-Wc++-compat</span></samp>.  It
1027can be disabled with the <samp><span class="option">-Wno-jump-misses-init</span></samp> option.
1028
1029     <br><dt><code>-Wsign-compare</code><dd><a name="index-Wsign_002dcompare-407"></a><a name="index-Wno_002dsign_002dcompare-408"></a><a name="index-warning-for-comparison-of-signed-and-unsigned-values-409"></a><a name="index-comparison-of-signed-and-unsigned-values_002c-warning-410"></a><a name="index-signed-and-unsigned-values_002c-comparison-warning-411"></a>Warn when a comparison between signed and unsigned values could produce
1030an incorrect result when the signed value is converted to unsigned. 
1031This warning is also enabled by <samp><span class="option">-Wextra</span></samp>; to get the other warnings
1032of <samp><span class="option">-Wextra</span></samp> without this warning, use &lsquo;<samp><span class="samp">-Wextra -Wno-sign-compare</span></samp>&rsquo;.
1033
1034     <br><dt><code>-Wsign-conversion</code><dd><a name="index-Wsign_002dconversion-412"></a><a name="index-Wno_002dsign_002dconversion-413"></a>Warn for implicit conversions that may change the sign of an integer
1035value, like assigning a signed integer expression to an unsigned
1036integer variable. An explicit cast silences the warning. In C, this
1037option is enabled also by <samp><span class="option">-Wconversion</span></samp>.
1038
1039     <br><dt><code>-Waddress</code><dd><a name="index-Waddress-414"></a><a name="index-Wno_002daddress-415"></a>Warn about suspicious uses of memory addresses. These include using
1040the address of a function in a conditional expression, such as
1041<code>void func(void); if (func)</code>, and comparisons against the memory
1042address of a string literal, such as <code>if (x == "abc")</code>.  Such
1043uses typically indicate a programmer error: the address of a function
1044always evaluates to true, so their use in a conditional usually
1045indicate that the programmer forgot the parentheses in a function
1046call; and comparisons against string literals result in unspecified
1047behavior and are not portable in C, so they usually indicate that the
1048programmer intended to use <code>strcmp</code>.  This warning is enabled by
1049<samp><span class="option">-Wall</span></samp>.
1050
1051     <br><dt><code>-Wlogical-op</code><dd><a name="index-Wlogical_002dop-416"></a><a name="index-Wno_002dlogical_002dop-417"></a>Warn about suspicious uses of logical operators in expressions. 
1052This includes using logical operators in contexts where a
1053bit-wise operator is likely to be expected.
1054
1055     <br><dt><code>-Waggregate-return</code><dd><a name="index-Waggregate_002dreturn-418"></a><a name="index-Wno_002daggregate_002dreturn-419"></a>Warn if any functions that return structures or unions are defined or
1056called.  (In languages where you can return an array, this also elicits
1057a warning.)
1058
1059     <br><dt><code>-Wno-attributes</code><dd><a name="index-Wno_002dattributes-420"></a><a name="index-Wattributes-421"></a>Do not warn if an unexpected <code>__attribute__</code> is used, such as
1060unrecognized attributes, function attributes applied to variables,
1061etc.  This will not stop errors for incorrect use of supported
1062attributes.
1063
1064     <br><dt><code>-Wno-builtin-macro-redefined</code><dd><a name="index-Wno_002dbuiltin_002dmacro_002dredefined-422"></a><a name="index-Wbuiltin_002dmacro_002dredefined-423"></a>Do not warn if certain built-in macros are redefined.  This suppresses
1065warnings for redefinition of <code>__TIMESTAMP__</code>, <code>__TIME__</code>,
1066<code>__DATE__</code>, <code>__FILE__</code>, and <code>__BASE_FILE__</code>.
1067
1068     <br><dt><code>-Wstrict-prototypes </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wstrict_002dprototypes-424"></a><a name="index-Wno_002dstrict_002dprototypes-425"></a>Warn if a function is declared or defined without specifying the
1069argument types.  (An old-style function definition is permitted without
1070a warning if preceded by a declaration which specifies the argument
1071types.)
1072
1073     <br><dt><code>-Wold-style-declaration </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wold_002dstyle_002ddeclaration-426"></a><a name="index-Wno_002dold_002dstyle_002ddeclaration-427"></a>Warn for obsolescent usages, according to the C Standard, in a
1074declaration. For example, warn if storage-class specifiers like
1075<code>static</code> are not the first things in a declaration.  This warning
1076is also enabled by <samp><span class="option">-Wextra</span></samp>.
1077
1078     <br><dt><code>-Wold-style-definition </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wold_002dstyle_002ddefinition-428"></a><a name="index-Wno_002dold_002dstyle_002ddefinition-429"></a>Warn if an old-style function definition is used.  A warning is given
1079even if there is a previous prototype.
1080
1081     <br><dt><code>-Wmissing-parameter-type </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wmissing_002dparameter_002dtype-430"></a><a name="index-Wno_002dmissing_002dparameter_002dtype-431"></a>A function parameter is declared without a type specifier in K&amp;R-style
1082functions:
1083
1084     <pre class="smallexample">          void foo(bar) { }
1085</pre>
1086     <p>This warning is also enabled by <samp><span class="option">-Wextra</span></samp>.
1087
1088     <br><dt><code>-Wmissing-prototypes </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wmissing_002dprototypes-432"></a><a name="index-Wno_002dmissing_002dprototypes-433"></a>Warn if a global function is defined without a previous prototype
1089declaration.  This warning is issued even if the definition itself
1090provides a prototype.  The aim is to detect global functions that fail
1091to be declared in header files.
1092
1093     <br><dt><code>-Wmissing-declarations</code><dd><a name="index-Wmissing_002ddeclarations-434"></a><a name="index-Wno_002dmissing_002ddeclarations-435"></a>Warn if a global function is defined without a previous declaration. 
1094Do so even if the definition itself provides a prototype. 
1095Use this option to detect global functions that are not declared in
1096header files.  In C++, no warnings are issued for function templates,
1097or for inline functions, or for functions in anonymous namespaces.
1098
1099     <br><dt><code>-Wmissing-field-initializers</code><dd><a name="index-Wmissing_002dfield_002dinitializers-436"></a><a name="index-Wno_002dmissing_002dfield_002dinitializers-437"></a><a name="index-W-438"></a><a name="index-Wextra-439"></a><a name="index-Wno_002dextra-440"></a>Warn if a structure's initializer has some fields missing.  For
1100example, the following code would cause such a warning, because
1101<code>x.h</code> is implicitly zero:
1102
1103     <pre class="smallexample">          struct s { int f, g, h; };
1104          struct s x = { 3, 4 };
1105</pre>
1106     <p>This option does not warn about designated initializers, so the following
1107modification would not trigger a warning:
1108
1109     <pre class="smallexample">          struct s { int f, g, h; };
1110          struct s x = { .f = 3, .g = 4 };
1111</pre>
1112     <p>This warning is included in <samp><span class="option">-Wextra</span></samp>.  To get other <samp><span class="option">-Wextra</span></samp>
1113warnings without this one, use &lsquo;<samp><span class="samp">-Wextra -Wno-missing-field-initializers</span></samp>&rsquo;.
1114
1115     <br><dt><code>-Wmissing-format-attribute</code><dd><a name="index-Wmissing_002dformat_002dattribute-441"></a><a name="index-Wno_002dmissing_002dformat_002dattribute-442"></a><a name="index-Wformat-443"></a><a name="index-Wno_002dformat-444"></a>Warn about function pointers which might be candidates for <code>format</code>
1116attributes.  Note these are only possible candidates, not absolute ones. 
1117GCC will guess that function pointers with <code>format</code> attributes that
1118are used in assignment, initialization, parameter passing or return
1119statements should have a corresponding <code>format</code> attribute in the
1120resulting type.  I.e. the left-hand side of the assignment or
1121initialization, the type of the parameter variable, or the return type
1122of the containing function respectively should also have a <code>format</code>
1123attribute to avoid the warning.
1124
1125     <p>GCC will also warn about function definitions which might be
1126candidates for <code>format</code> attributes.  Again, these are only
1127possible candidates.  GCC will guess that <code>format</code> attributes
1128might be appropriate for any function that calls a function like
1129<code>vprintf</code> or <code>vscanf</code>, but this might not always be the
1130case, and some functions for which <code>format</code> attributes are
1131appropriate may not be detected.
1132
1133     <br><dt><code>-Wno-multichar</code><dd><a name="index-Wno_002dmultichar-445"></a><a name="index-Wmultichar-446"></a>Do not warn if a multicharacter constant (&lsquo;<samp><span class="samp">'FOOF'</span></samp>&rsquo;) is used. 
1134Usually they indicate a typo in the user's code, as they have
1135implementation-defined values, and should not be used in portable code.
1136
1137     <br><dt><code>-Wnormalized=&lt;none|id|nfc|nfkc&gt;</code><dd><a name="index-Wnormalized_003d-447"></a><a name="index-NFC-448"></a><a name="index-NFKC-449"></a><a name="index-character-set_002c-input-normalization-450"></a>In ISO C and ISO C++, two identifiers are different if they are
1138different sequences of characters.  However, sometimes when characters
1139outside the basic ASCII character set are used, you can have two
1140different character sequences that look the same.  To avoid confusion,
1141the ISO 10646 standard sets out some <dfn>normalization rules</dfn> which
1142when applied ensure that two sequences that look the same are turned into
1143the same sequence.  GCC can warn you if you are using identifiers which
1144have not been normalized; this option controls that warning.
1145
1146     <p>There are four levels of warning that GCC supports.  The default is
1147<samp><span class="option">-Wnormalized=nfc</span></samp>, which warns about any identifier which is
1148not in the ISO 10646 &ldquo;C&rdquo; normalized form, <dfn>NFC</dfn>.  NFC is the
1149recommended form for most uses.
1150
1151     <p>Unfortunately, there are some characters which ISO C and ISO C++ allow
1152in identifiers that when turned into NFC aren't allowable as
1153identifiers.  That is, there's no way to use these symbols in portable
1154ISO C or C++ and have all your identifiers in NFC. 
1155<samp><span class="option">-Wnormalized=id</span></samp> suppresses the warning for these characters. 
1156It is hoped that future versions of the standards involved will correct
1157this, which is why this option is not the default.
1158
1159     <p>You can switch the warning off for all characters by writing
1160<samp><span class="option">-Wnormalized=none</span></samp>.  You would only want to do this if you
1161were using some other normalization scheme (like &ldquo;D&rdquo;), because
1162otherwise you can easily create bugs that are literally impossible to see.
1163
1164     <p>Some characters in ISO 10646 have distinct meanings but look identical
1165in some fonts or display methodologies, especially once formatting has
1166been applied.  For instance <code>\u207F</code>, &ldquo;SUPERSCRIPT LATIN SMALL
1167LETTER N&rdquo;, will display just like a regular <code>n</code> which has been
1168placed in a superscript.  ISO 10646 defines the <dfn>NFKC</dfn>
1169normalization scheme to convert all these into a standard form as
1170well, and GCC will warn if your code is not in NFKC if you use
1171<samp><span class="option">-Wnormalized=nfkc</span></samp>.  This warning is comparable to warning
1172about every identifier that contains the letter O because it might be
1173confused with the digit 0, and so is not the default, but may be
1174useful as a local coding convention if the programming environment is
1175unable to be fixed to display these characters distinctly.
1176
1177     <br><dt><code>-Wno-deprecated</code><dd><a name="index-Wno_002ddeprecated-451"></a><a name="index-Wdeprecated-452"></a>Do not warn about usage of deprecated features.  See <a href="Deprecated-Features.html#Deprecated-Features">Deprecated Features</a>.
1178
1179     <br><dt><code>-Wno-deprecated-declarations</code><dd><a name="index-Wno_002ddeprecated_002ddeclarations-453"></a><a name="index-Wdeprecated_002ddeclarations-454"></a>Do not warn about uses of functions (see <a href="Function-Attributes.html#Function-Attributes">Function Attributes</a>),
1180variables (see <a href="Variable-Attributes.html#Variable-Attributes">Variable Attributes</a>), and types (see <a href="Type-Attributes.html#Type-Attributes">Type Attributes</a>) marked as deprecated by using the <code>deprecated</code>
1181attribute.
1182
1183     <br><dt><code>-Wno-overflow</code><dd><a name="index-Wno_002doverflow-455"></a><a name="index-Woverflow-456"></a>Do not warn about compile-time overflow in constant expressions.
1184
1185     <br><dt><code>-Woverride-init </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Woverride_002dinit-457"></a><a name="index-Wno_002doverride_002dinit-458"></a><a name="index-W-459"></a><a name="index-Wextra-460"></a><a name="index-Wno_002dextra-461"></a>Warn if an initialized field without side effects is overridden when
1186using designated initializers (see <a href="Designated-Inits.html#Designated-Inits">Designated Initializers</a>).
1187
1188     <p>This warning is included in <samp><span class="option">-Wextra</span></samp>.  To get other
1189<samp><span class="option">-Wextra</span></samp> warnings without this one, use &lsquo;<samp><span class="samp">-Wextra
1190-Wno-override-init</span></samp>&rsquo;.
1191
1192     <br><dt><code>-Wpacked</code><dd><a name="index-Wpacked-462"></a><a name="index-Wno_002dpacked-463"></a>Warn if a structure is given the packed attribute, but the packed
1193attribute has no effect on the layout or size of the structure. 
1194Such structures may be mis-aligned for little benefit.  For
1195instance, in this code, the variable <code>f.x</code> in <code>struct bar</code>
1196will be misaligned even though <code>struct bar</code> does not itself
1197have the packed attribute:
1198
1199     <pre class="smallexample">          struct foo {
1200            int x;
1201            char a, b, c, d;
1202          } __attribute__((packed));
1203          struct bar {
1204            char z;
1205            struct foo f;
1206          };
1207</pre>
1208     <br><dt><code>-Wpacked-bitfield-compat</code><dd><a name="index-Wpacked_002dbitfield_002dcompat-464"></a><a name="index-Wno_002dpacked_002dbitfield_002dcompat-465"></a>The 4.1, 4.2 and 4.3 series of GCC ignore the <code>packed</code> attribute
1209on bit-fields of type <code>char</code>.  This has been fixed in GCC 4.4 but
1210the change can lead to differences in the structure layout.  GCC
1211informs you when the offset of such a field has changed in GCC 4.4. 
1212For example there is no longer a 4-bit padding between field <code>a</code>
1213and <code>b</code> in this structure:
1214
1215     <pre class="smallexample">          struct foo
1216          {
1217            char a:4;
1218            char b:8;
1219          } __attribute__ ((packed));
1220</pre>
1221     <p>This warning is enabled by default.  Use
1222<samp><span class="option">-Wno-packed-bitfield-compat</span></samp> to disable this warning.
1223
1224     <br><dt><code>-Wpadded</code><dd><a name="index-Wpadded-466"></a><a name="index-Wno_002dpadded-467"></a>Warn if padding is included in a structure, either to align an element
1225of the structure or to align the whole structure.  Sometimes when this
1226happens it is possible to rearrange the fields of the structure to
1227reduce the padding and so make the structure smaller.
1228
1229     <br><dt><code>-Wredundant-decls</code><dd><a name="index-Wredundant_002ddecls-468"></a><a name="index-Wno_002dredundant_002ddecls-469"></a>Warn if anything is declared more than once in the same scope, even in
1230cases where multiple declaration is valid and changes nothing.
1231
1232     <br><dt><code>-Wnested-externs </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wnested_002dexterns-470"></a><a name="index-Wno_002dnested_002dexterns-471"></a>Warn if an <code>extern</code> declaration is encountered within a function.
1233
1234     <br><dt><code>-Winline</code><dd><a name="index-Winline-472"></a><a name="index-Wno_002dinline-473"></a>Warn if a function can not be inlined and it was declared as inline. 
1235Even with this option, the compiler will not warn about failures to
1236inline functions declared in system headers.
1237
1238     <p>The compiler uses a variety of heuristics to determine whether or not
1239to inline a function.  For example, the compiler takes into account
1240the size of the function being inlined and the amount of inlining
1241that has already been done in the current function.  Therefore,
1242seemingly insignificant changes in the source program can cause the
1243warnings produced by <samp><span class="option">-Winline</span></samp> to appear or disappear.
1244
1245     <br><dt><code>-Wno-invalid-offsetof </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wno_002dinvalid_002doffsetof-474"></a><a name="index-Winvalid_002doffsetof-475"></a>Suppress warnings from applying the &lsquo;<samp><span class="samp">offsetof</span></samp>&rsquo; macro to a non-POD
1246type.  According to the 1998 ISO C++ standard, applying &lsquo;<samp><span class="samp">offsetof</span></samp>&rsquo;
1247to a non-POD type is undefined.  In existing C++ implementations,
1248however, &lsquo;<samp><span class="samp">offsetof</span></samp>&rsquo; typically gives meaningful results even when
1249applied to certain kinds of non-POD types. (Such as a simple
1250&lsquo;<samp><span class="samp">struct</span></samp>&rsquo; that fails to be a POD type only by virtue of having a
1251constructor.)  This flag is for users who are aware that they are
1252writing nonportable code and who have deliberately chosen to ignore the
1253warning about it.
1254
1255     <p>The restrictions on &lsquo;<samp><span class="samp">offsetof</span></samp>&rsquo; may be relaxed in a future version
1256of the C++ standard.
1257
1258     <br><dt><code>-Wno-int-to-pointer-cast</code><dd><a name="index-Wno_002dint_002dto_002dpointer_002dcast-476"></a><a name="index-Wint_002dto_002dpointer_002dcast-477"></a>Suppress warnings from casts to pointer type of an integer of a
1259different size. In C++, casting to a pointer type of smaller size is
1260an error. <samp><span class="option">Wint-to-pointer-cast</span></samp> is enabled by default.
1261
1262     <br><dt><code>-Wno-pointer-to-int-cast </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wno_002dpointer_002dto_002dint_002dcast-478"></a><a name="index-Wpointer_002dto_002dint_002dcast-479"></a>Suppress warnings from casts from a pointer to an integer type of a
1263different size.
1264
1265     <br><dt><code>-Winvalid-pch</code><dd><a name="index-Winvalid_002dpch-480"></a><a name="index-Wno_002dinvalid_002dpch-481"></a>Warn if a precompiled header (see <a href="Precompiled-Headers.html#Precompiled-Headers">Precompiled Headers</a>) is found in
1266the search path but can't be used.
1267
1268     <br><dt><code>-Wlong-long</code><dd><a name="index-Wlong_002dlong-482"></a><a name="index-Wno_002dlong_002dlong-483"></a>Warn if &lsquo;<samp><span class="samp">long long</span></samp>&rsquo; type is used.  This is enabled by either
1269<samp><span class="option">-pedantic</span></samp> or <samp><span class="option">-Wtraditional</span></samp> in ISO C90 and C++98
1270modes.  To inhibit the warning messages, use <samp><span class="option">-Wno-long-long</span></samp>.
1271
1272     <br><dt><code>-Wvariadic-macros</code><dd><a name="index-Wvariadic_002dmacros-484"></a><a name="index-Wno_002dvariadic_002dmacros-485"></a>Warn if variadic macros are used in pedantic ISO C90 mode, or the GNU
1273alternate syntax when in pedantic ISO C99 mode.  This is default. 
1274To inhibit the warning messages, use <samp><span class="option">-Wno-variadic-macros</span></samp>.
1275
1276     <br><dt><code>-Wvla</code><dd><a name="index-Wvla-486"></a><a name="index-Wno_002dvla-487"></a>Warn if variable length array is used in the code. 
1277<samp><span class="option">-Wno-vla</span></samp> will prevent the <samp><span class="option">-pedantic</span></samp> warning of
1278the variable length array.
1279
1280     <br><dt><code>-Wvolatile-register-var</code><dd><a name="index-Wvolatile_002dregister_002dvar-488"></a><a name="index-Wno_002dvolatile_002dregister_002dvar-489"></a>Warn if a register variable is declared volatile.  The volatile
1281modifier does not inhibit all optimizations that may eliminate reads
1282and/or writes to register variables.  This warning is enabled by
1283<samp><span class="option">-Wall</span></samp>.
1284
1285     <br><dt><code>-Wdisabled-optimization</code><dd><a name="index-Wdisabled_002doptimization-490"></a><a name="index-Wno_002ddisabled_002doptimization-491"></a>Warn if a requested optimization pass is disabled.  This warning does
1286not generally indicate that there is anything wrong with your code; it
1287merely indicates that GCC's optimizers were unable to handle the code
1288effectively.  Often, the problem is that your code is too big or too
1289complex; GCC will refuse to optimize programs when the optimization
1290itself is likely to take inordinate amounts of time.
1291
1292     <br><dt><code>-Wpointer-sign </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wpointer_002dsign-492"></a><a name="index-Wno_002dpointer_002dsign-493"></a>Warn for pointer argument passing or assignment with different signedness. 
1293This option is only supported for C and Objective-C.  It is implied by
1294<samp><span class="option">-Wall</span></samp> and by <samp><span class="option">-pedantic</span></samp>, which can be disabled with
1295<samp><span class="option">-Wno-pointer-sign</span></samp>.
1296
1297     <br><dt><code>-Wstack-protector</code><dd><a name="index-Wstack_002dprotector-494"></a><a name="index-Wno_002dstack_002dprotector-495"></a>This option is only active when <samp><span class="option">-fstack-protector</span></samp> is active.  It
1298warns about functions that will not be protected against stack smashing.
1299
1300     <br><dt><code>-Wno-mudflap</code><dd><a name="index-Wno_002dmudflap-496"></a>Suppress warnings about constructs that cannot be instrumented by
1301<samp><span class="option">-fmudflap</span></samp>.
1302
1303     <br><dt><code>-Woverlength-strings</code><dd><a name="index-Woverlength_002dstrings-497"></a><a name="index-Wno_002doverlength_002dstrings-498"></a>Warn about string constants which are longer than the &ldquo;minimum
1304maximum&rdquo; length specified in the C standard.  Modern compilers
1305generally allow string constants which are much longer than the
1306standard's minimum limit, but very portable programs should avoid
1307using longer strings.
1308
1309     <p>The limit applies <em>after</em> string constant concatenation, and does
1310not count the trailing NUL.  In C90, the limit was 509 characters; in
1311C99, it was raised to 4095.  C++98 does not specify a normative
1312minimum maximum, so we do not diagnose overlength strings in C++.
1313
1314     <p>This option is implied by <samp><span class="option">-pedantic</span></samp>, and can be disabled with
1315<samp><span class="option">-Wno-overlength-strings</span></samp>.
1316
1317     <br><dt><code>-Wunsuffixed-float-constants </code><span class="roman">(C and Objective-C only)</span><dd><a name="index-Wunsuffixed_002dfloat_002dconstants-499"></a>
1318GCC will issue a warning for any floating constant that does not have
1319a suffix.  When used together with <samp><span class="option">-Wsystem-headers</span></samp> it will
1320warn about such constants in system header files.  This can be useful
1321when preparing code to use with the <code>FLOAT_CONST_DECIMAL64</code> pragma
1322from the decimal floating-point extension to C99. 
1323</dl>
1324
1325 </body></html>
1326
1327