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 * Covariant returns are implemented for all but varadic functions that
74 require an adjustment.
76 *** Changes in GCC 3.3:
78 * The "new X = 3" extension has been removed; you must now use "new X(3)".
80 * G++ no longer allows in-class initializations of static data members
81 that do not have arithmetic or enumeration type. For example:
84 static const char* const p = "abc";
87 is no longer accepted.
89 Use the standards-conformant form:
92 static const char* const p;
95 const char* const S::p = "abc";
99 (ISO C++ is even stricter; it does not allow in-class
100 initializations of floating-point types.)
102 *** Changes in GCC 3.1:
104 * -fhonor-std and -fno-honor-std have been removed. -fno-honor-std was
105 a workaround to allow std compliant code to work with the non-std
106 compliant libstdc++-v2. libstdc++-v3 is std compliant.
108 * The C++ ABI has been fixed so that `void (A::*)() const' is mangled as
109 "M1AKFvvE", rather than "MK1AFvvE" as before. This change only affects
110 pointer to cv-qualified member function types.
112 * The C++ ABI has been changed to correctly handle this code:
115 void operator delete[] (void *, size_t);
118 struct B : public A {
123 The amount of storage allocated for the array will be greater than
124 it was in 3.0, in order to store the number of elements in the
125 array, so that the correct size can be passed to `operator delete[]'
126 when the array is deleted. Previously, the value passed to
127 `operator delete[]' was unpredictable.
129 This change will only affect code that declares a two-argument
130 `operator delete[]' with a second parameter of type `size_t'
131 in a base class, and does not override that definition in a
134 * The C++ ABI has been changed so that:
137 void operator delete[] (void *, size_t);
138 void operator delete[] (void *);
141 does not cause unnecessary storage to be allocated when an array of
142 `A' objects is allocated.
144 This change will only affect code that declares both of these
145 forms of `operator delete[]', and declared the two-argument form
146 before the one-argument form.
148 * The C++ ABI has been changed so that when a parameter is passed by value,
149 any cleanup for that parameter is performed in the caller, as specified
150 by the ia64 C++ ABI, rather than the called function as before. As a
151 result, classes with a non-trivial destructor but a trivial copy
152 constructor will be passed and returned by invisible reference, rather
153 than by bitwise copy as before.
155 * G++ now supports the "named return value optimization": for code like
163 G++ will allocate 'a' in the return value slot, so that the return
164 becomes a no-op. For this to work, all return statements in the function
165 must return the same variable.
167 *** Changes in GCC 3.0:
169 * Support for guiding declarations has been removed.
171 * G++ now supports importing member functions from base classes with a
174 * G++ now enforces access control for nested types.
176 * In some obscure cases, functions with the same type could have the
177 same mangled name. This bug caused compiler crashes, link-time clashes,
178 and debugger crashes. Fixing this bug required breaking ABI
179 compatibility for the functions involved. The functions in questions
180 are those whose types involve non-type template arguments whose
181 mangled representations require more than one digit.
183 * Support for assignment to `this' has been removed. This idiom
184 was used in the very early days of C++, before users were allowed
185 to overload `operator new'; it is no longer allowed by the C++
188 * Support for signatures, a G++ extension, have been removed.
190 * Certain invalid conversions that were previously accepted will now
191 be rejected. For example, assigning function pointers of one type
192 to function pointers of another type now requires a cast, whereas
193 previously g++ would sometimes accept the code even without the
196 * G++ previously allowed `sizeof (X::Y)' where Y was a non-static
197 member of X, even if the `sizeof' expression occurred outside
198 of a non-static member function of X (or one of its derived classes,
199 or a member-initializer for X or one of its derived classes.) This
200 extension has been removed.
202 * G++ no longer allows you to overload the conditional operator (i.e.,
205 * The "named return value" extension:
207 int f () return r { r = 3; }
209 has been deprecated, and will be removed in a future version of G++.
211 *** Changes in GCC 2.95:
213 * Messages about non-conformant code that we can still handle ("pedwarns")
214 are now errors by default, rather than warnings. This can be reverted
215 with -fpermissive, and is overridden by -pedantic or -pedantic-errors.
217 * String constants are now of type `const char[n]', rather than `char[n]'.
218 This can be reverted with -fno-const-strings.
220 * References to functions are now supported.
222 * Lookup of class members during class definition now works in all cases.
224 * In overload resolution, type conversion operators are now properly
225 treated as always coming from the most derived class.
227 * C9x-style restricted pointers are supported, using the `__restrict'
230 * You can now use -fno-implicit-inline-templates to suppress writing out
231 implicit instantiations of inline templates. Normally we do write them
232 out, even with -fno-implicit-templates, so that optimization doesn't
233 affect which instantiations are needed.
235 * -fstrict-prototype now also suppresses implicit declarations.
237 * Many obsolete options have been removed: -fall-virtual, -fmemoize-lookups,
238 -fsave-memoized, +e?, -fenum-int-equivalence, -fno-nonnull-objects.
240 * Unused virtual functions can be discarded on some targets by specifying
241 -ffunction-sections -fvtable-gc to the compiler and --gc-sections to the
242 linker. Unfortunately, this only works on Linux if you're linking
245 * Lots of bugs stomped.
247 *** Changes in EGCS 1.1:
249 * Namespaces are fully supported. The library has not yet been converted
250 to use namespace std, however, and the old std-faking code is still on by
251 default. To turn it off, you can use -fhonor-std.
253 * Massive template improvements:
254 + member template classes are supported.
255 + template friends are supported.
256 + template template parameters are supported.
257 + local classes in templates are supported.
258 + lots of bugs fixed.
260 * operator new now throws bad_alloc where appropriate.
262 * Exception handling is now thread safe, and supports nested exceptions and
263 placement delete. Exception handling overhead on x86 is much lower with
266 * protected virtual inheritance is now supported.
268 * Loops are optimized better; we now move the test to the end in most
269 cases, like the C frontend does.
271 * For class D derived from B which has a member 'int i', &D::i is now of
272 type 'int B::*' instead of 'int D::*'.
274 * An _experimental_ new ABI for g++ can be turned on with -fnew-abi. The
275 current features of this are more efficient allocation of base classes
276 (including the empty base optimization), and more compact mangling of C++
277 symbol names (which can be turned on separately with -fsquangle). This
278 ABI is subject to change without notice, so don't use it for anything
279 that you don't want to rebuild with every release of the compiler.
281 As with all ABI-changing flags, this flag is for experts only, as all
282 code (including the library code in libgcc and libstdc++) must be
283 compiled with the same ABI.
285 *** Changes in EGCS 1.0:
287 * A public review copy of the December 1996 Draft of the ISO/ANSI C++
288 standard is now available. See
290 http://www.cygnus.com/misc/wp/
292 for more information.
294 * g++ now uses a new implementation of templates. The basic idea is that
295 now templates are minimally parsed when seen and then expanded later.
296 This allows conformant early name binding and instantiation controls,
297 since instantiations no longer have to go through the parser.
301 + Inlining of template functions works without any extra effort or
303 + Instantiations of class templates and methods defined in the class
304 body are deferred until they are actually needed (unless
305 -fexternal-templates is specified).
306 + Nested types in class templates work.
307 + Static data member templates work.
308 + Member function templates are now supported.
309 + Partial specialization of class templates is now supported.
310 + Explicit specification of template parameters to function templates
313 Things you may need to fix in your code:
315 + Syntax errors in templates that are never instantiated will now be
317 + Types and class templates used in templates must be declared
318 first, or the compiler will assume they are not types, and fail.
319 + Similarly, nested types of template type parameters must be tagged
320 with the 'typename' keyword, except in base lists. In many cases,
321 but not all, the compiler will tell you where you need to add
322 'typename'. For more information, see
324 http://www.cygnus.com/misc/wp/dec96pub/template.html#temp.res
326 + Guiding declarations are no longer supported. Function declarations,
327 including friend declarations, do not refer to template instantiations.
328 You can restore the old behavior with -fguiding-decls until you fix
333 + Default function arguments in templates will not be evaluated (or
334 checked for semantic validity) unless they are needed. Default
335 arguments in class bodies will not be parsed until the class
336 definition is complete.
337 + The -ftemplate-depth-NN flag can be used to increase the maximum
338 recursive template instantiation depth, which defaults to 17. If you
339 need to use this flag, the compiler will tell you.
340 + Explicit instantiation of template constructors and destructors is
341 now supported. For instance:
343 template A<int>::A(const A&);
347 + Member class templates.
350 * Exception handling support has been significantly improved and is on by
351 default. The compiler supports two mechanisms for walking back up the
352 call stack; one relies on static information about how registers are
353 saved, and causes no runtime overhead for code that does not throw
354 exceptions. The other mechanism uses setjmp and longjmp equivalents, and
355 can result in quite a bit of runtime overhead. You can determine which
356 mechanism is the default for your target by compiling a testcase that
357 uses exceptions and doing an 'nm' on the object file; if it uses __throw,
358 it's using the first mechanism. If it uses __sjthrow, it's using the
361 You can turn EH support off with -fno-exceptions.
363 * RTTI support has been rewritten to work properly and is now on by default.
364 This means code that uses virtual functions will have a modest space
365 overhead. You can use the -fno-rtti flag to disable RTTI support.
367 * On ELF systems, duplicate copies of symbols with 'initialized common'
368 linkage (such as template instantiations, vtables, and extern inlines)
369 will now be discarded by the GNU linker, so you don't need to use -frepo.
370 This support requires GNU ld from binutils 2.8 or later.
372 * The overload resolution code has been rewritten to conform to the latest
373 C++ Working Paper. Built-in operators are now considered as candidates
374 in operator overload resolution. Function template overloading chooses
375 the more specialized template, and handles base classes in type deduction
376 and guiding declarations properly. In this release the old code can
377 still be selected with -fno-ansi-overloading, although this is not
378 supported and will be removed in a future release.
380 * Standard usage syntax for the std namespace is supported; std is treated
381 as an alias for global scope. General namespaces are still not supported.
385 + New warning -Wno-pmf-conversion (don't warn about
386 converting from a bound member function pointer to function
389 + A flag -Weffc++ has been added for violations of some of the style
390 guidelines in Scott Meyers' _Effective C++_ books.
392 + -Woverloaded-virtual now warns if a virtual function in a base
393 class is hidden in a derived class, rather than warning about
394 virtual functions being overloaded (even if all of the inherited
395 signatures are overridden) as it did before.
397 + -Wall no longer implies -W. The new warning flag, -Wsign-compare,
398 included in -Wall, warns about dangerous comparisons of signed and
399 unsigned values. Only the flag is new; it was previously part of
402 + The new flag, -fno-weak, disables the use of weak symbols.
404 * Synthesized methods are now emitted in any translation units that need
405 an out-of-line copy. They are no longer affected by #pragma interface
406 or #pragma implementation.
408 * __FUNCTION__ and __PRETTY_FUNCTION__ are now treated as variables by the
409 parser; previously they were treated as string constants. So code like
410 `printf (__FUNCTION__ ": foo")' must be rewritten to
411 `printf ("%s: foo", __FUNCTION__)'. This is necessary for templates.
413 * local static variables in extern inline functions will be shared between
416 * -fvtable-thunks is supported for all targets, and is the default for
417 Linux with glibc 2.x (also called libc 6.x).
419 * bool is now always the same size as another built-in type. Previously,
420 a 64-bit RISC target using a 32-bit ABI would have 32-bit pointers and a
421 64-bit bool. This should only affect Irix 6, which was not supported in
424 * new (nothrow) is now supported.
426 * Synthesized destructors are no longer made virtual just because the class
427 already has virtual functions, only if they override a virtual destructor
428 in a base class. The compiler will warn if this affects your code.
430 * The g++ driver now only links against libstdc++, not libg++; it is
431 functionally identical to the c++ driver.
433 * (void *)0 is no longer considered a null pointer constant; NULL in
434 <stddef.h> is now defined as __null, a magic constant of type (void *)
435 normally, or (size_t) with -ansi.
437 * The name of a class is now implicitly declared in its own scope; A::A
440 * Local classes are now supported.
442 * __attribute__ can now be attached to types as well as declarations.
444 * The compiler no longer emits a warning if an ellipsis is used as a
445 function's argument list.
447 * Definition of nested types outside of their containing class is now
448 supported. For instance:
459 * On the HPPA, some classes that do not define a copy constructor
460 will be passed and returned in memory again so that functions
461 returning those types can be inlined.
463 *** The g++ team thanks everyone that contributed to this release,
466 * Joe Buck <jbuck@synopsys.com>, the maintainer of the g++ FAQ.
467 * Brendan Kehoe <brendan@cygnus.com>, who coordinates testing of g++.
468 * Jason Merrill <jason@cygnus.com>, the g++ maintainer.
469 * Mark Mitchell <mmitchell@usa.net>, who implemented member function
470 templates and explicit qualification of function templates.
471 * Mike Stump <mrs@wrs.com>, the previous g++ maintainer, who did most of
472 the exception handling work.