• 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>C++ Dialect 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="C-Dialect-Options.html#C-Dialect-Options" title="C Dialect Options">
10<link rel="next" href="Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options.html#Objective_002dC-and-Objective_002dC_002b_002b-Dialect-Options" title="Objective-C and Objective-C++ Dialect 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="C++-Dialect-Options"></a>
51<a name="C_002b_002b-Dialect-Options"></a>
52<p>
53Next:&nbsp;<a rel="next" accesskey="n" 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>,
54Previous:&nbsp;<a rel="previous" accesskey="p" href="C-Dialect-Options.html#C-Dialect-Options">C Dialect Options</a>,
55Up:&nbsp;<a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a>
56<hr>
57</div>
58
59<h3 class="section">3.5 Options Controlling C++ Dialect</h3>
60
61<p><a name="index-compiler-options_002c-C_002b_002b-128"></a><a name="index-C_002b_002b-options_002c-command-line-129"></a><a name="index-options_002c-C_002b_002b-130"></a>This section describes the command-line options that are only meaningful
62for C++ programs; but you can also use most of the GNU compiler options
63regardless of what language your program is in.  For example, you
64might compile a file <code>firstClass.C</code> like this:
65
66<pre class="smallexample">     g++ -g -frepo -O -c firstClass.C
67</pre>
68 <p class="noindent">In this example, only <samp><span class="option">-frepo</span></samp> is an option meant
69only for C++ programs; you can use the other options with any
70language supported by GCC.
71
72 <p>Here is a list of options that are <em>only</em> for compiling C++ programs:
73
74     <dl>
75<dt><code>-fabi-version=</code><var>n</var><dd><a name="index-fabi_002dversion-131"></a>Use version <var>n</var> of the C++ ABI.  Version 2 is the version of the
76C++ ABI that first appeared in G++ 3.4.  Version 1 is the version of
77the C++ ABI that first appeared in G++ 3.2.  Version 0 will always be
78the version that conforms most closely to the C++ ABI specification. 
79Therefore, the ABI obtained using version 0 will change as ABI bugs
80are fixed.
81
82     <p>The default is version 2.
83
84     <p>Version 3 corrects an error in mangling a constant address as a
85template argument.
86
87     <p>Version 4 implements a standard mangling for vector types.
88
89     <p>Version 5 corrects the mangling of attribute const/volatile on
90function pointer types, decltype of a plain decl, and use of a
91function parameter in the declaration of another parameter.
92
93     <p>See also <samp><span class="option">-Wabi</span></samp>.
94
95     <br><dt><code>-fno-access-control</code><dd><a name="index-fno_002daccess_002dcontrol-132"></a>Turn off all access checking.  This switch is mainly useful for working
96around bugs in the access control code.
97
98     <br><dt><code>-fcheck-new</code><dd><a name="index-fcheck_002dnew-133"></a>Check that the pointer returned by <code>operator new</code> is non-null
99before attempting to modify the storage allocated.  This check is
100normally unnecessary because the C++ standard specifies that
101<code>operator new</code> will only return <code>0</code> if it is declared
102&lsquo;<samp><span class="samp">throw()</span></samp>&rsquo;, in which case the compiler will always check the
103return value even without this option.  In all other cases, when
104<code>operator new</code> has a non-empty exception specification, memory
105exhaustion is signalled by throwing <code>std::bad_alloc</code>.  See also
106&lsquo;<samp><span class="samp">new (nothrow)</span></samp>&rsquo;.
107
108     <br><dt><code>-fconserve-space</code><dd><a name="index-fconserve_002dspace-134"></a>Put uninitialized or runtime-initialized global variables into the
109common segment, as C does.  This saves space in the executable at the
110cost of not diagnosing duplicate definitions.  If you compile with this
111flag and your program mysteriously crashes after <code>main()</code> has
112completed, you may have an object that is being destroyed twice because
113two definitions were merged.
114
115     <p>This option is no longer useful on most targets, now that support has
116been added for putting variables into BSS without making them common.
117
118     <br><dt><code>-fconstexpr-depth=</code><var>n</var><dd><a name="index-fconstexpr_002ddepth-135"></a>Set the maximum nested evaluation depth for C++0x constexpr functions
119to <var>n</var>.  A limit is needed to detect endless recursion during
120constant expression evaluation.  The minimum specified by the standard
121is 512.
122
123     <br><dt><code>-fno-deduce-init-list</code><dd><a name="index-fno_002ddeduce_002dinit_002dlist-136"></a>Disable deduction of a template type parameter as
124std::initializer_list from a brace-enclosed initializer list, i.e.
125
126     <pre class="smallexample">          template &lt;class T&gt; auto forward(T t) -&gt; decltype (realfn (t))
127          {
128            return realfn (t);
129          }
130          
131          void f()
132          {
133            forward({1,2}); // call forward&lt;std::initializer_list&lt;int&gt;&gt;
134          }
135</pre>
136     <p>This option is present because this deduction is an extension to the
137current specification in the C++0x working draft, and there was
138some concern about potential overload resolution problems.
139
140     <br><dt><code>-ffriend-injection</code><dd><a name="index-ffriend_002dinjection-137"></a>Inject friend functions into the enclosing namespace, so that they are
141visible outside the scope of the class in which they are declared. 
142Friend functions were documented to work this way in the old Annotated
143C++ Reference Manual, and versions of G++ before 4.1 always worked
144that way.  However, in ISO C++ a friend function which is not declared
145in an enclosing scope can only be found using argument dependent
146lookup.  This option causes friends to be injected as they were in
147earlier releases.
148
149     <p>This option is for compatibility, and may be removed in a future
150release of G++.
151
152     <br><dt><code>-fno-elide-constructors</code><dd><a name="index-fno_002delide_002dconstructors-138"></a>The C++ standard allows an implementation to omit creating a temporary
153which is only used to initialize another object of the same type. 
154Specifying this option disables that optimization, and forces G++ to
155call the copy constructor in all cases.
156
157     <br><dt><code>-fno-enforce-eh-specs</code><dd><a name="index-fno_002denforce_002deh_002dspecs-139"></a>Don't generate code to check for violation of exception specifications
158at runtime.  This option violates the C++ standard, but may be useful
159for reducing code size in production builds, much like defining
160&lsquo;<samp><span class="samp">NDEBUG</span></samp>&rsquo;.  This does not give user code permission to throw
161exceptions in violation of the exception specifications; the compiler
162will still optimize based on the specifications, so throwing an
163unexpected exception will result in undefined behavior.
164
165     <br><dt><code>-ffor-scope</code><dt><code>-fno-for-scope</code><dd><a name="index-ffor_002dscope-140"></a><a name="index-fno_002dfor_002dscope-141"></a>If <samp><span class="option">-ffor-scope</span></samp> is specified, the scope of variables declared in
166a <i>for-init-statement</i> is limited to the &lsquo;<samp><span class="samp">for</span></samp>&rsquo; loop itself,
167as specified by the C++ standard. 
168If <samp><span class="option">-fno-for-scope</span></samp> is specified, the scope of variables declared in
169a <i>for-init-statement</i> extends to the end of the enclosing scope,
170as was the case in old versions of G++, and other (traditional)
171implementations of C++.
172
173     <p>The default if neither flag is given to follow the standard,
174but to allow and give a warning for old-style code that would
175otherwise be invalid, or have different behavior.
176
177     <br><dt><code>-fno-gnu-keywords</code><dd><a name="index-fno_002dgnu_002dkeywords-142"></a>Do not recognize <code>typeof</code> as a keyword, so that code can use this
178word as an identifier.  You can use the keyword <code>__typeof__</code> instead. 
179<samp><span class="option">-ansi</span></samp> implies <samp><span class="option">-fno-gnu-keywords</span></samp>.
180
181     <br><dt><code>-fno-implicit-templates</code><dd><a name="index-fno_002dimplicit_002dtemplates-143"></a>Never emit code for non-inline templates which are instantiated
182implicitly (i.e. by use); only emit code for explicit instantiations. 
183See <a href="Template-Instantiation.html#Template-Instantiation">Template Instantiation</a>, for more information.
184
185     <br><dt><code>-fno-implicit-inline-templates</code><dd><a name="index-fno_002dimplicit_002dinline_002dtemplates-144"></a>Don't emit code for implicit instantiations of inline templates, either. 
186The default is to handle inlines differently so that compiles with and
187without optimization will need the same set of explicit instantiations.
188
189     <br><dt><code>-fno-implement-inlines</code><dd><a name="index-fno_002dimplement_002dinlines-145"></a>To save space, do not emit out-of-line copies of inline functions
190controlled by &lsquo;<samp><span class="samp">#pragma implementation</span></samp>&rsquo;.  This will cause linker
191errors if these functions are not inlined everywhere they are called.
192
193     <br><dt><code>-fms-extensions</code><dd><a name="index-fms_002dextensions-146"></a>Disable pedantic warnings about constructs used in MFC, such as implicit
194int and getting a pointer to member function via non-standard syntax.
195
196     <br><dt><code>-fno-nonansi-builtins</code><dd><a name="index-fno_002dnonansi_002dbuiltins-147"></a>Disable built-in declarations of functions that are not mandated by
197ANSI/ISO C.  These include <code>ffs</code>, <code>alloca</code>, <code>_exit</code>,
198<code>index</code>, <code>bzero</code>, <code>conjf</code>, and other related functions.
199
200     <br><dt><code>-fnothrow-opt</code><dd><a name="index-fnothrow_002dopt-148"></a>Treat a <code>throw()</code> exception specification as though it were a
201<code>noexcept</code> specification to reduce or eliminate the text size
202overhead relative to a function with no exception specification.  If
203the function has local variables of types with non-trivial
204destructors, the exception specification will actually make the
205function smaller because the EH cleanups for those variables can be
206optimized away.  The semantic effect is that an exception thrown out of
207a function with such an exception specification will result in a call
208to <code>terminate</code> rather than <code>unexpected</code>.
209
210     <br><dt><code>-fno-operator-names</code><dd><a name="index-fno_002doperator_002dnames-149"></a>Do not treat the operator name keywords <code>and</code>, <code>bitand</code>,
211<code>bitor</code>, <code>compl</code>, <code>not</code>, <code>or</code> and <code>xor</code> as
212synonyms as keywords.
213
214     <br><dt><code>-fno-optional-diags</code><dd><a name="index-fno_002doptional_002ddiags-150"></a>Disable diagnostics that the standard says a compiler does not need to
215issue.  Currently, the only such diagnostic issued by G++ is the one for
216a name having multiple meanings within a class.
217
218     <br><dt><code>-fpermissive</code><dd><a name="index-fpermissive-151"></a>Downgrade some diagnostics about nonconformant code from errors to
219warnings.  Thus, using <samp><span class="option">-fpermissive</span></samp> will allow some
220nonconforming code to compile.
221
222     <br><dt><code>-fno-pretty-templates</code><dd><a name="index-fno_002dpretty_002dtemplates-152"></a>When an error message refers to a specialization of a function
223template, the compiler will normally print the signature of the
224template followed by the template arguments and any typedefs or
225typenames in the signature (e.g. <code>void f(T) [with T = int]</code>
226rather than <code>void f(int)</code>) so that it's clear which template is
227involved.  When an error message refers to a specialization of a class
228template, the compiler will omit any template arguments which match
229the default template arguments for that template.  If either of these
230behaviors make it harder to understand the error message rather than
231easier, using <samp><span class="option">-fno-pretty-templates</span></samp> will disable them.
232
233     <br><dt><code>-frepo</code><dd><a name="index-frepo-153"></a>Enable automatic template instantiation at link time.  This option also
234implies <samp><span class="option">-fno-implicit-templates</span></samp>.  See <a href="Template-Instantiation.html#Template-Instantiation">Template Instantiation</a>, for more information.
235
236     <br><dt><code>-fno-rtti</code><dd><a name="index-fno_002drtti-154"></a>Disable generation of information about every class with virtual
237functions for use by the C++ runtime type identification features
238(&lsquo;<samp><span class="samp">dynamic_cast</span></samp>&rsquo; and &lsquo;<samp><span class="samp">typeid</span></samp>&rsquo;).  If you don't use those parts
239of the language, you can save some space by using this flag.  Note that
240exception handling uses the same information, but it will generate it as
241needed. The &lsquo;<samp><span class="samp">dynamic_cast</span></samp>&rsquo; operator can still be used for casts that
242do not require runtime type information, i.e. casts to <code>void *</code> or to
243unambiguous base classes.
244
245     <br><dt><code>-fstats</code><dd><a name="index-fstats-155"></a>Emit statistics about front-end processing at the end of the compilation. 
246This information is generally only useful to the G++ development team.
247
248     <br><dt><code>-fstrict-enums</code><dd><a name="index-fstrict_002denums-156"></a>Allow the compiler to optimize using the assumption that a value of
249enumeration type can only be one of the values of the enumeration (as
250defined in the C++ standard; basically, a value which can be
251represented in the minimum number of bits needed to represent all the
252enumerators).  This assumption may not be valid if the program uses a
253cast to convert an arbitrary integer value to the enumeration type.
254
255     <br><dt><code>-ftemplate-depth=</code><var>n</var><dd><a name="index-ftemplate_002ddepth-157"></a>Set the maximum instantiation depth for template classes to <var>n</var>. 
256A limit on the template instantiation depth is needed to detect
257endless recursions during template class instantiation.  ANSI/ISO C++
258conforming programs must not rely on a maximum depth greater than 17
259(changed to 1024 in C++0x).
260
261     <br><dt><code>-fno-threadsafe-statics</code><dd><a name="index-fno_002dthreadsafe_002dstatics-158"></a>Do not emit the extra code to use the routines specified in the C++
262ABI for thread-safe initialization of local statics.  You can use this
263option to reduce code size slightly in code that doesn't need to be
264thread-safe.
265
266     <br><dt><code>-fuse-cxa-atexit</code><dd><a name="index-fuse_002dcxa_002datexit-159"></a>Register destructors for objects with static storage duration with the
267<code>__cxa_atexit</code> function rather than the <code>atexit</code> function. 
268This option is required for fully standards-compliant handling of static
269destructors, but will only work if your C library supports
270<code>__cxa_atexit</code>.
271
272     <br><dt><code>-fno-use-cxa-get-exception-ptr</code><dd><a name="index-fno_002duse_002dcxa_002dget_002dexception_002dptr-160"></a>Don't use the <code>__cxa_get_exception_ptr</code> runtime routine.  This
273will cause <code>std::uncaught_exception</code> to be incorrect, but is necessary
274if the runtime routine is not available.
275
276     <br><dt><code>-fvisibility-inlines-hidden</code><dd><a name="index-fvisibility_002dinlines_002dhidden-161"></a>This switch declares that the user does not attempt to compare
277pointers to inline methods where the addresses of the two functions
278were taken in different shared objects.
279
280     <p>The effect of this is that GCC may, effectively, mark inline methods with
281<code>__attribute__ ((visibility ("hidden")))</code> so that they do not
282appear in the export table of a DSO and do not require a PLT indirection
283when used within the DSO.  Enabling this option can have a dramatic effect
284on load and link times of a DSO as it massively reduces the size of the
285dynamic export table when the library makes heavy use of templates.
286
287     <p>The behavior of this switch is not quite the same as marking the
288methods as hidden directly, because it does not affect static variables
289local to the function or cause the compiler to deduce that
290the function is defined in only one shared object.
291
292     <p>You may mark a method as having a visibility explicitly to negate the
293effect of the switch for that method.  For example, if you do want to
294compare pointers to a particular inline method, you might mark it as
295having default visibility.  Marking the enclosing class with explicit
296visibility will have no effect.
297
298     <p>Explicitly instantiated inline methods are unaffected by this option
299as their linkage might otherwise cross a shared library boundary. 
300See <a href="Template-Instantiation.html#Template-Instantiation">Template Instantiation</a>.
301
302     <br><dt><code>-fvisibility-ms-compat</code><dd><a name="index-fvisibility_002dms_002dcompat-162"></a>This flag attempts to use visibility settings to make GCC's C++
303linkage model compatible with that of Microsoft Visual Studio.
304
305     <p>The flag makes these changes to GCC's linkage model:
306
307          <ol type=1 start=1>
308<li>It sets the default visibility to <code>hidden</code>, like
309<samp><span class="option">-fvisibility=hidden</span></samp>.
310
311          <li>Types, but not their members, are not hidden by default.
312
313          <li>The One Definition Rule is relaxed for types without explicit
314visibility specifications which are defined in more than one different
315shared object: those declarations are permitted if they would have
316been permitted when this option was not used.
317          </ol>
318
319     <p>In new code it is better to use <samp><span class="option">-fvisibility=hidden</span></samp> and
320export those classes which are intended to be externally visible. 
321Unfortunately it is possible for code to rely, perhaps accidentally,
322on the Visual Studio behavior.
323
324     <p>Among the consequences of these changes are that static data members
325of the same type with the same name but defined in different shared
326objects will be different, so changing one will not change the other;
327and that pointers to function members defined in different shared
328objects may not compare equal.  When this flag is given, it is a
329violation of the ODR to define types with the same name differently.
330
331     <br><dt><code>-fno-weak</code><dd><a name="index-fno_002dweak-163"></a>Do not use weak symbol support, even if it is provided by the linker. 
332By default, G++ will use weak symbols if they are available.  This
333option exists only for testing, and should not be used by end-users;
334it will result in inferior code and has no benefits.  This option may
335be removed in a future release of G++.
336
337     <br><dt><code>-nostdinc++</code><dd><a name="index-nostdinc_002b_002b-164"></a>Do not search for header files in the standard directories specific to
338C++, but do still search the other standard directories.  (This option
339is used when building the C++ library.) 
340</dl>
341
342 <p>In addition, these optimization, warning, and code generation options
343have meanings only for C++ programs:
344
345     <dl>
346<dt><code>-fno-default-inline</code><dd><a name="index-fno_002ddefault_002dinline-165"></a>Do not assume &lsquo;<samp><span class="samp">inline</span></samp>&rsquo; for functions defined inside a class scope. 
347See <a href="Optimize-Options.html#Optimize-Options">Options That Control Optimization</a>.  Note that these
348functions will have linkage like inline functions; they just won't be
349inlined by default.
350
351     <br><dt><code>-Wabi </code><span class="roman">(C, Objective-C, C++ and Objective-C++ only)</span><dd><a name="index-Wabi-166"></a><a name="index-Wno_002dabi-167"></a>Warn when G++ generates code that is probably not compatible with the
352vendor-neutral C++ ABI.  Although an effort has been made to warn about
353all such cases, there are probably some cases that are not warned about,
354even though G++ is generating incompatible code.  There may also be
355cases where warnings are emitted even though the code that is generated
356will be compatible.
357
358     <p>You should rewrite your code to avoid these warnings if you are
359concerned about the fact that code generated by G++ may not be binary
360compatible with code generated by other compilers.
361
362     <p>The known incompatibilities in <samp><span class="option">-fabi-version=2</span></samp> (the default) include:
363
364          <ul>
365<li>A template with a non-type template parameter of reference type is
366mangled incorrectly:
367          <pre class="smallexample">               extern int N;
368               template &lt;int &amp;&gt; struct S {};
369               void n (S&lt;N&gt;) {2}
370</pre>
371          <p>This is fixed in <samp><span class="option">-fabi-version=3</span></samp>.
372
373          <li>SIMD vector types declared using <code>__attribute ((vector_size))</code> are
374mangled in a non-standard way that does not allow for overloading of
375functions taking vectors of different sizes.
376
377          <p>The mangling is changed in <samp><span class="option">-fabi-version=4</span></samp>. 
378</ul>
379
380     <p>The known incompatibilities in <samp><span class="option">-fabi-version=1</span></samp> include:
381
382          <ul>
383<li>Incorrect handling of tail-padding for bit-fields.  G++ may attempt to
384pack data into the same byte as a base class.  For example:
385
386          <pre class="smallexample">               struct A { virtual void f(); int f1 : 1; };
387               struct B : public A { int f2 : 1; };
388</pre>
389          <p class="noindent">In this case, G++ will place <code>B::f2</code> into the same byte
390as<code>A::f1</code>; other compilers will not.  You can avoid this problem
391by explicitly padding <code>A</code> so that its size is a multiple of the
392byte size on your platform; that will cause G++ and other compilers to
393layout <code>B</code> identically.
394
395          <li>Incorrect handling of tail-padding for virtual bases.  G++ does not use
396tail padding when laying out virtual bases.  For example:
397
398          <pre class="smallexample">               struct A { virtual void f(); char c1; };
399               struct B { B(); char c2; };
400               struct C : public A, public virtual B {};
401</pre>
402          <p class="noindent">In this case, G++ will not place <code>B</code> into the tail-padding for
403<code>A</code>; other compilers will.  You can avoid this problem by
404explicitly padding <code>A</code> so that its size is a multiple of its
405alignment (ignoring virtual base classes); that will cause G++ and other
406compilers to layout <code>C</code> identically.
407
408          <li>Incorrect handling of bit-fields with declared widths greater than that
409of their underlying types, when the bit-fields appear in a union.  For
410example:
411
412          <pre class="smallexample">               union U { int i : 4096; };
413</pre>
414          <p class="noindent">Assuming that an <code>int</code> does not have 4096 bits, G++ will make the
415union too small by the number of bits in an <code>int</code>.
416
417          <li>Empty classes can be placed at incorrect offsets.  For example:
418
419          <pre class="smallexample">               struct A {};
420               
421               struct B {
422                 A a;
423                 virtual void f ();
424               };
425               
426               struct C : public B, public A {};
427</pre>
428          <p class="noindent">G++ will place the <code>A</code> base class of <code>C</code> at a nonzero offset;
429it should be placed at offset zero.  G++ mistakenly believes that the
430<code>A</code> data member of <code>B</code> is already at offset zero.
431
432          <li>Names of template functions whose types involve <code>typename</code> or
433template template parameters can be mangled incorrectly.
434
435          <pre class="smallexample">               template &lt;typename Q&gt;
436               void f(typename Q::X) {}
437               
438               template &lt;template &lt;typename&gt; class Q&gt;
439               void f(typename Q&lt;int&gt;::X) {}
440</pre>
441          <p class="noindent">Instantiations of these templates may be mangled incorrectly.
442
443     </ul>
444
445     <p>It also warns psABI related changes.  The known psABI changes at this
446point include:
447
448          <ul>
449<li>For SYSV/x86-64, when passing union with long double, it is changed to
450pass in memory as specified in psABI.  For example:
451
452          <pre class="smallexample">               union U {
453                 long double ld;
454                 int i;
455               };
456</pre>
457          <p class="noindent"><code>union U</code> will always be passed in memory.
458
459     </ul>
460
461     <br><dt><code>-Wctor-dtor-privacy </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wctor_002ddtor_002dprivacy-168"></a><a name="index-Wno_002dctor_002ddtor_002dprivacy-169"></a>Warn when a class seems unusable because all the constructors or
462destructors in that class are private, and it has neither friends nor
463public static member functions.
464
465     <br><dt><code>-Wnoexcept </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wnoexcept-170"></a><a name="index-Wno_002dnoexcept-171"></a>Warn when a noexcept-expression evaluates to false because of a call
466to a function that does not have a non-throwing exception
467specification (i.e. &lsquo;<samp><span class="samp">throw()</span></samp>&rsquo; or &lsquo;<samp><span class="samp">noexcept</span></samp>&rsquo;) but is known by
468the compiler to never throw an exception.
469
470     <br><dt><code>-Wnon-virtual-dtor </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wnon_002dvirtual_002ddtor-172"></a><a name="index-Wno_002dnon_002dvirtual_002ddtor-173"></a>Warn when a class has virtual functions and accessible non-virtual
471destructor, in which case it would be possible but unsafe to delete
472an instance of a derived class through a pointer to the base class. 
473This warning is also enabled if -Weffc++ is specified.
474
475     <br><dt><code>-Wreorder </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wreorder-174"></a><a name="index-Wno_002dreorder-175"></a><a name="index-reordering_002c-warning-176"></a><a name="index-warning-for-reordering-of-member-initializers-177"></a>Warn when the order of member initializers given in the code does not
476match the order in which they must be executed.  For instance:
477
478     <pre class="smallexample">          struct A {
479            int i;
480            int j;
481            A(): j (0), i (1) { }
482          };
483</pre>
484     <p>The compiler will rearrange the member initializers for &lsquo;<samp><span class="samp">i</span></samp>&rsquo;
485and &lsquo;<samp><span class="samp">j</span></samp>&rsquo; to match the declaration order of the members, emitting
486a warning to that effect.  This warning is enabled by <samp><span class="option">-Wall</span></samp>. 
487</dl>
488
489 <p>The following <samp><span class="option">-W...</span></samp> options are not affected by <samp><span class="option">-Wall</span></samp>.
490
491     <dl>
492<dt><code>-Weffc++ </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Weffc_002b_002b-178"></a><a name="index-Wno_002deffc_002b_002b-179"></a>Warn about violations of the following style guidelines from Scott Meyers'
493<cite>Effective C++</cite> book:
494
495          <ul>
496<li>Item 11:  Define a copy constructor and an assignment operator for classes
497with dynamically allocated memory.
498
499          <li>Item 12:  Prefer initialization to assignment in constructors.
500
501          <li>Item 14:  Make destructors virtual in base classes.
502
503          <li>Item 15:  Have <code>operator=</code> return a reference to <code>*this</code>.
504
505          <li>Item 23:  Don't try to return a reference when you must return an object.
506
507     </ul>
508
509     <p>Also warn about violations of the following style guidelines from
510Scott Meyers' <cite>More Effective C++</cite> book:
511
512          <ul>
513<li>Item 6:  Distinguish between prefix and postfix forms of increment and
514decrement operators.
515
516          <li>Item 7:  Never overload <code>&amp;&amp;</code>, <code>||</code>, or <code>,</code>.
517
518     </ul>
519
520     <p>When selecting this option, be aware that the standard library
521headers do not obey all of these guidelines; use &lsquo;<samp><span class="samp">grep -v</span></samp>&rsquo;
522to filter out those warnings.
523
524     <br><dt><code>-Wstrict-null-sentinel </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wstrict_002dnull_002dsentinel-180"></a><a name="index-Wno_002dstrict_002dnull_002dsentinel-181"></a>Warn also about the use of an uncasted <code>NULL</code> as sentinel.  When
525compiling only with GCC this is a valid sentinel, as <code>NULL</code> is defined
526to <code>__null</code>.  Although it is a null pointer constant not a null pointer,
527it is guaranteed to be of the same size as a pointer.  But this use is
528not portable across different compilers.
529
530     <br><dt><code>-Wno-non-template-friend </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wno_002dnon_002dtemplate_002dfriend-182"></a><a name="index-Wnon_002dtemplate_002dfriend-183"></a>Disable warnings when non-templatized friend functions are declared
531within a template.  Since the advent of explicit template specification
532support in G++, if the name of the friend is an unqualified-id (i.e.,
533&lsquo;<samp><span class="samp">friend foo(int)</span></samp>&rsquo;), the C++ language specification demands that the
534friend declare or define an ordinary, nontemplate function.  (Section
53514.5.3).  Before G++ implemented explicit specification, unqualified-ids
536could be interpreted as a particular specialization of a templatized
537function.  Because this non-conforming behavior is no longer the default
538behavior for G++, <samp><span class="option">-Wnon-template-friend</span></samp> allows the compiler to
539check existing code for potential trouble spots and is on by default. 
540This new compiler behavior can be turned off with
541<samp><span class="option">-Wno-non-template-friend</span></samp> which keeps the conformant compiler code
542but disables the helpful warning.
543
544     <br><dt><code>-Wold-style-cast </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wold_002dstyle_002dcast-184"></a><a name="index-Wno_002dold_002dstyle_002dcast-185"></a>Warn if an old-style (C-style) cast to a non-void type is used within
545a C++ program.  The new-style casts (&lsquo;<samp><span class="samp">dynamic_cast</span></samp>&rsquo;,
546&lsquo;<samp><span class="samp">static_cast</span></samp>&rsquo;, &lsquo;<samp><span class="samp">reinterpret_cast</span></samp>&rsquo;, and &lsquo;<samp><span class="samp">const_cast</span></samp>&rsquo;) are
547less vulnerable to unintended effects and much easier to search for.
548
549     <br><dt><code>-Woverloaded-virtual </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Woverloaded_002dvirtual-186"></a><a name="index-Wno_002doverloaded_002dvirtual-187"></a><a name="index-overloaded-virtual-function_002c-warning-188"></a><a name="index-warning-for-overloaded-virtual-function-189"></a>Warn when a function declaration hides virtual functions from a
550base class.  For example, in:
551
552     <pre class="smallexample">          struct A {
553            virtual void f();
554          };
555          
556          struct B: public A {
557            void f(int);
558          };
559</pre>
560     <p>the <code>A</code> class version of <code>f</code> is hidden in <code>B</code>, and code
561like:
562
563     <pre class="smallexample">          B* b;
564          b-&gt;f();
565</pre>
566     <p>will fail to compile.
567
568     <br><dt><code>-Wno-pmf-conversions </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wno_002dpmf_002dconversions-190"></a><a name="index-Wpmf_002dconversions-191"></a>Disable the diagnostic for converting a bound pointer to member function
569to a plain pointer.
570
571     <br><dt><code>-Wsign-promo </code><span class="roman">(C++ and Objective-C++ only)</span><dd><a name="index-Wsign_002dpromo-192"></a><a name="index-Wno_002dsign_002dpromo-193"></a>Warn when overload resolution chooses a promotion from unsigned or
572enumerated type to a signed type, over a conversion to an unsigned type of
573the same size.  Previous versions of G++ would try to preserve
574unsignedness, but the standard mandates the current behavior.
575
576     <pre class="smallexample">          struct A {
577            operator int ();
578            A&amp; operator = (int);
579          };
580          
581          main ()
582          {
583            A a,b;
584            a = b;
585          }
586</pre>
587     <p>In this example, G++ will synthesize a default &lsquo;<samp><span class="samp">A&amp; operator =
588(const A&amp;);</span></samp>&rsquo;, while cfront will use the user-defined &lsquo;<samp><span class="samp">operator =</span></samp>&rsquo;. 
589</dl>
590
591 </body></html>
592
593