gcc 4.5
只拣一些有用的:
The -fshow-column
option is now on by default. This
means error messages now have a column associated with them.
A new built-in function __builtin_unreachable()
has been added that tells the compiler that control will never
reach that point. It may be used after asm
statements that terminate by transferring control elsewhere, and
in other places that are known to be unreachable.
-Wlogical-op
option now warns for logical
expressions such as (c == 1 && c == 2)
and (c
!= 1 || c != 2),
which are likely to be mistakes. This
option is disabled by default.
The new -Wjump-misses-init
option warns about
cases where a goto
or switch
skips the
initialization of a variable. This sort of branch is an error in
C++ but not in C. This warning is enabled
by -Wc++-compat
.
GCC now implements C90- and C99-conforming rules for constant expressions. This may cause warnings or errors for some code using expressions that can be folded to a constant but are not constant expressions as defined by ISO C.
Access control is now applied to typedef
names used in
a template, which may cause G++ to reject some ill-formed code that was
accepted by earlier releases. The -fno-access-control
flag can be used as a temporary workaround until the code is
corrected.
Compilation time for code that uses templates should now scale linearly with the number of instantiations rather than quadratically, as template instantiations are now looked up using hash tables.
G++ now implements DR 176 . Previously G++ did not support using the injected-class-name of a template base class as a type name, and lookup of the name found the declaration of the template in the enclosing scope. Now lookup of the name finds the injected-class-name, which can be used either as a type or as a template, depending on whether or not the name is followed by a template argument list. As a result of this change, some code that was previously accepted may be ill-formed because
- The injected-class-name is not accessible because it's from a private base, or
- The injected-class-name cannot be used as an argument for a template template parameter.
In either of these cases, the code can be fixed by adding a
nested-name-specifier to explicitly name the template. The first can
be worked around with -fno-access-control
; the second is
only rejected with -pedantic
.