1 *** Changes in GCC 3.4:
3 * The C++ parser in G++ has been rewritten from scratch. As a result, G++
4 is considerably more compliant to the C++ standard. As a result, it
5 accepts more valid programs, and rejects more invalid programs.
7 Many of the changes below are a consequence of the new parser.
9 * Friend declarations that refer to template specializations are rejected
10 if the template has not already been declared.
19 is rejected; you must first declare `f' as a template:
24 * You must use "template <>" to introduce template specializations, as
25 required by the standard. For example:
32 is rejected; you must write:
34 template <> struct S<int> {};
36 * You must now use the `typename' and `template' keywords to disambiguate
37 dependent names, as required by the C++ standard.
39 * The "named return value" extension has been removed.
41 * The "implicit typename" extension has been removed.
43 * G++ used to accept code like this:
51 This behavior is not mandated by the standard.
53 Now G++ issues an error about this code. To avoid the error, you must
54 move the declaration of `g' before the declaration of `f'. The
55 default arguments for `g' must be visible at the point where it is
58 * When -pedantic is used, G++ now issues errors about spurious semicolons;
61 namespace N {}; // Invalid semicolon.
62 void f() {}; // Invalid semicolon.
64 * G++ no longer accepts attributes for a declarator after the
65 initializer associated with that declarator. For example:
67 X x(1) __attribute__((...));
69 is no longer accepted. Instead, use:
71 X x __attribute__((...)) (1);
73 *** Changes in GCC 3.3:
75 * The "new X = 3" extension has been removed; you must now use "new X(3)".
77 * G++ no longer allows in-class initializations of static data members
78 that do not have arithmetic or enumeration type. For example:
81 static const char* const p = "abc";
84 is no longer accepted.
86 Use the standards-conformant form:
89 static const char* const p;
92 const char* const S::p = "abc";
96 (ISO C++ is even stricter; it does not allow in-class
97 initializations of floating-point types.)
99 *** Changes in GCC 3.1:
101 * -fhonor-std and -fno-honor-std have been removed. -fno-honor-std was
102 a workaround to allow std compliant code to work with the non-std
103 compliant libstdc++-v2. libstdc++-v3 is std compliant.
105 * The C++ ABI has been fixed so that `void (A::*)() const' is mangled as
106 "M1AKFvvE", rather than "MK1AFvvE" as before. This change only affects
107 pointer to cv-qualified member function types.
109 * The C++ ABI has been changed to correctly handle this code:
112 void operator delete[] (void *, size_t);
115 struct B : public A {
120 The amount of storage allocated for the array will be greater than
121 it was in 3.0, in order to store the number of elements in the
122 array, so that the correct size can be passed to `operator delete[]'
123 when the array is deleted. Previously, the value passed to
124 `operator delete[]' was unpredictable.
126 This change will only affect code that declares a two-argument
127 `operator delete[]' with a second parameter of type `size_t'
128 in a base class, and does not override that definition in a
131 * The C++ ABI has been changed so that:
134 void operator delete[] (void *, size_t);
135 void operator delete[] (void *);
138 does not cause unnecessary storage to be allocated when an array of
139 `A' objects is allocated.
141 This change will only affect code that declares both of these
142 forms of `operator delete[]', and declared the two-argument form
143 before the one-argument form.
145 * The C++ ABI has been changed so that when a parameter is passed by value,
146 any cleanup for that parameter is performed in the caller, as specified
147 by the ia64 C++ ABI, rather than the called function as before. As a
148 result, classes with a non-trivial destructor but a trivial copy
149 constructor will be passed and returned by invisible reference, rather
150 than by bitwise copy as before.
152 * G++ now supports the "named return value optimization": for code like
160 G++ will allocate 'a' in the return value slot, so that the return
161 becomes a no-op. For this to work, all return statements in the function
162 must return the same variable.
164 *** Changes in GCC 3.0:
166 * Support for guiding declarations has been removed.
168 * G++ now supports importing member functions from base classes with a
171 * G++ now enforces access control for nested types.
173 * In some obscure cases, functions with the same type could have the
174 same mangled name. This bug caused compiler crashes, link-time clashes,
175 and debugger crashes. Fixing this bug required breaking ABI
176 compatibility for the functions involved. The functions in questions
177 are those whose types involve non-type template arguments whose
178 mangled representations require more than one digit.
180 * Support for assignment to `this' has been removed. This idiom
181 was used in the very early days of C++, before users were allowed
182 to overload `operator new'; it is no longer allowed by the C++
185 * Support for signatures, a G++ extension, have been removed.
187 * Certain invalid conversions that were previously accepted will now
188 be rejected. For example, assigning function pointers of one type
189 to function pointers of another type now requires a cast, whereas
190 previously g++ would sometimes accept the code even without the
193 * G++ previously allowed `sizeof (X::Y)' where Y was a non-static
194 member of X, even if the `sizeof' expression occurred outside
195 of a non-static member function of X (or one of its derived classes,
196 or a member-initializer for X or one of its derived classes.) This
197 extension has been removed.
199 * G++ no longer allows you to overload the conditional operator (i.e.,
202 * The "named return value" extension:
204 int f () return r { r = 3; }
206 has been deprecated, and will be removed in a future version of G++.
208 *** Changes in GCC 2.95:
210 * Messages about non-conformant code that we can still handle ("pedwarns")
211 are now errors by default, rather than warnings. This can be reverted
212 with -fpermissive, and is overridden by -pedantic or -pedantic-errors.
214 * String constants are now of type `const char[n]', rather than `char[n]'.
215 This can be reverted with -fno-const-strings.
217 * References to functions are now supported.
219 * Lookup of class members during class definition now works in all cases.
221 * In overload resolution, type conversion operators are now properly
222 treated as always coming from the most derived class.
224 * C9x-style restricted pointers are supported, using the `__restrict'
227 * You can now use -fno-implicit-inline-templates to suppress writing out
228 implicit instantiations of inline templates. Normally we do write them
229 out, even with -fno-implicit-templates, so that optimization doesn't
230 affect which instantiations are needed.
232 * -fstrict-prototype now also suppresses implicit declarations.
234 * Many obsolete options have been removed: -fall-virtual, -fmemoize-lookups,
235 -fsave-memoized, +e?, -fenum-int-equivalence, -fno-nonnull-objects.
237 * Unused virtual functions can be discarded on some targets by specifying
238 -ffunction-sections -fvtable-gc to the compiler and --gc-sections to the
239 linker. Unfortunately, this only works on Linux if you're linking
242 * Lots of bugs stomped.
244 *** Changes in EGCS 1.1:
246 * Namespaces are fully supported. The library has not yet been converted
247 to use namespace std, however, and the old std-faking code is still on by
248 default. To turn it off, you can use -fhonor-std.
250 * Massive template improvements:
251 + member template classes are supported.
252 + template friends are supported.
253 + template template parameters are supported.
254 + local classes in templates are supported.
255 + lots of bugs fixed.
257 * operator new now throws bad_alloc where appropriate.
259 * Exception handling is now thread safe, and supports nested exceptions and
260 placement delete. Exception handling overhead on x86 is much lower with
263 * protected virtual inheritance is now supported.
265 * Loops are optimized better; we now move the test to the end in most
266 cases, like the C frontend does.
268 * For class D derived from B which has a member 'int i', &D::i is now of
269 type 'int B::*' instead of 'int D::*'.
271 * An _experimental_ new ABI for g++ can be turned on with -fnew-abi. The
272 current features of this are more efficient allocation of base classes
273 (including the empty base optimization), and more compact mangling of C++
274 symbol names (which can be turned on separately with -fsquangle). This
275 ABI is subject to change without notice, so don't use it for anything
276 that you don't want to rebuild with every release of the compiler.
278 As with all ABI-changing flags, this flag is for experts only, as all
279 code (including the library code in libgcc and libstdc++) must be
280 compiled with the same ABI.
282 *** Changes in EGCS 1.0:
284 * A public review copy of the December 1996 Draft of the ISO/ANSI C++
285 standard is now available. See
287 http://www.cygnus.com/misc/wp/
289 for more information.
291 * g++ now uses a new implementation of templates. The basic idea is that
292 now templates are minimally parsed when seen and then expanded later.
293 This allows conformant early name binding and instantiation controls,
294 since instantiations no longer have to go through the parser.
298 + Inlining of template functions works without any extra effort or
300 + Instantiations of class templates and methods defined in the class
301 body are deferred until they are actually needed (unless
302 -fexternal-templates is specified).
303 + Nested types in class templates work.
304 + Static data member templates work.
305 + Member function templates are now supported.
306 + Partial specialization of class templates is now supported.
307 + Explicit specification of template parameters to function templates
310 Things you may need to fix in your code:
312 + Syntax errors in templates that are never instantiated will now be
314 + Types and class templates used in templates must be declared
315 first, or the compiler will assume they are not types, and fail.
316 + Similarly, nested types of template type parameters must be tagged
317 with the 'typename' keyword, except in base lists. In many cases,
318 but not all, the compiler will tell you where you need to add
319 'typename'. For more information, see
321 http://www.cygnus.com/misc/wp/dec96pub/template.html#temp.res
323 + Guiding declarations are no longer supported. Function declarations,
324 including friend declarations, do not refer to template instantiations.
325 You can restore the old behavior with -fguiding-decls until you fix
330 + Default function arguments in templates will not be evaluated (or
331 checked for semantic validity) unless they are needed. Default
332 arguments in class bodies will not be parsed until the class
333 definition is complete.
334 + The -ftemplate-depth-NN flag can be used to increase the maximum
335 recursive template instantiation depth, which defaults to 17. If you
336 need to use this flag, the compiler will tell you.
337 + Explicit instantiation of template constructors and destructors is
338 now supported. For instance:
340 template A<int>::A(const A&);
344 + Member class templates.
347 * Exception handling support has been significantly improved and is on by
348 default. The compiler supports two mechanisms for walking back up the
349 call stack; one relies on static information about how registers are
350 saved, and causes no runtime overhead for code that does not throw
351 exceptions. The other mechanism uses setjmp and longjmp equivalents, and
352 can result in quite a bit of runtime overhead. You can determine which
353 mechanism is the default for your target by compiling a testcase that
354 uses exceptions and doing an 'nm' on the object file; if it uses __throw,
355 it's using the first mechanism. If it uses __sjthrow, it's using the
358 You can turn EH support off with -fno-exceptions.
360 * RTTI support has been rewritten to work properly and is now on by default.
361 This means code that uses virtual functions will have a modest space
362 overhead. You can use the -fno-rtti flag to disable RTTI support.
364 * On ELF systems, duplicate copies of symbols with 'initialized common'
365 linkage (such as template instantiations, vtables, and extern inlines)
366 will now be discarded by the GNU linker, so you don't need to use -frepo.
367 This support requires GNU ld from binutils 2.8 or later.
369 * The overload resolution code has been rewritten to conform to the latest
370 C++ Working Paper. Built-in operators are now considered as candidates
371 in operator overload resolution. Function template overloading chooses
372 the more specialized template, and handles base classes in type deduction
373 and guiding declarations properly. In this release the old code can
374 still be selected with -fno-ansi-overloading, although this is not
375 supported and will be removed in a future release.
377 * Standard usage syntax for the std namespace is supported; std is treated
378 as an alias for global scope. General namespaces are still not supported.
382 + New warning -Wno-pmf-conversion (don't warn about
383 converting from a bound member function pointer to function
386 + A flag -Weffc++ has been added for violations of some of the style
387 guidelines in Scott Meyers' _Effective C++_ books.
389 + -Woverloaded-virtual now warns if a virtual function in a base
390 class is hidden in a derived class, rather than warning about
391 virtual functions being overloaded (even if all of the inherited
392 signatures are overridden) as it did before.
394 + -Wall no longer implies -W. The new warning flag, -Wsign-compare,
395 included in -Wall, warns about dangerous comparisons of signed and
396 unsigned values. Only the flag is new; it was previously part of
399 + The new flag, -fno-weak, disables the use of weak symbols.
401 * Synthesized methods are now emitted in any translation units that need
402 an out-of-line copy. They are no longer affected by #pragma interface
403 or #pragma implementation.
405 * __FUNCTION__ and __PRETTY_FUNCTION__ are now treated as variables by the
406 parser; previously they were treated as string constants. So code like
407 `printf (__FUNCTION__ ": foo")' must be rewritten to
408 `printf ("%s: foo", __FUNCTION__)'. This is necessary for templates.
410 * local static variables in extern inline functions will be shared between
413 * -fvtable-thunks is supported for all targets, and is the default for
414 Linux with glibc 2.x (also called libc 6.x).
416 * bool is now always the same size as another built-in type. Previously,
417 a 64-bit RISC target using a 32-bit ABI would have 32-bit pointers and a
418 64-bit bool. This should only affect Irix 6, which was not supported in
421 * new (nothrow) is now supported.
423 * Synthesized destructors are no longer made virtual just because the class
424 already has virtual functions, only if they override a virtual destructor
425 in a base class. The compiler will warn if this affects your code.
427 * The g++ driver now only links against libstdc++, not libg++; it is
428 functionally identical to the c++ driver.
430 * (void *)0 is no longer considered a null pointer constant; NULL in
431 <stddef.h> is now defined as __null, a magic constant of type (void *)
432 normally, or (size_t) with -ansi.
434 * The name of a class is now implicitly declared in its own scope; A::A
437 * Local classes are now supported.
439 * __attribute__ can now be attached to types as well as declarations.
441 * The compiler no longer emits a warning if an ellipsis is used as a
442 function's argument list.
444 * Definition of nested types outside of their containing class is now
445 supported. For instance:
456 * On the HPPA, some classes that do not define a copy constructor
457 will be passed and returned in memory again so that functions
458 returning those types can be inlined.
460 *** The g++ team thanks everyone that contributed to this release,
463 * Joe Buck <jbuck@synopsys.com>, the maintainer of the g++ FAQ.
464 * Brendan Kehoe <brendan@cygnus.com>, who coordinates testing of g++.
465 * Jason Merrill <jason@cygnus.com>, the g++ maintainer.
466 * Mark Mitchell <mmitchell@usa.net>, who implemented member function
467 templates and explicit qualification of function templates.
468 * Mike Stump <mrs@wrs.com>, the previous g++ maintainer, who did most of
469 the exception handling work.