GCC 4.6

bearophile bearophileHUGS at lycos.com
Sat Mar 26 14:51:22 PDT 2011


Some changes in the new version of GCC, 4.6:

New warnings (I want something similar in D too):

>New -Wunused-but-set-variable and -Wunused-but-set-parameter warnings were added for C, C++, Objective-C and Objective-C++. These warnings diagnose variables respective parameters which are only set in the code and never otherwise used. Usually such variables are useless and often even the value assigned to them is computed needlessly, sometimes expensively. The -Wunused-but-set-variable warning is enabled by default by -Wall flag and -Wunused-but-set-parameter by -Wall -Wextra flags.<


Link-Time Optimizations is now more powerful:

>GCC itself, Mozilla Firefox and other large applications can be built with LTO enabled.<


>Static constructors and destructors from individual units are inlined into a single function. This can significantly improve startup times of large C++ applications where static constructors are very common. <


>Improved auto-detection of const and pure functions. Newly, noreturn functions are auto-detected.<


Interesting:

>The -Wsuggest-attribute=[const|pure|noreturn] flag is available that informs users when adding attributes to headers might improve code generation.<

-Wsuggest-attribute=[pure|const|noreturn]
    Warn for cases where adding an attribute may be beneficial. The attributes currently supported are listed below.
    -Wsuggest-attribute=pure
    -Wsuggest-attribute=const
    -Wsuggest-attribute=noreturn
        Warn about functions which might be candidates for attributes pure, const or noreturn. The compiler only warns for functions visible in other compilation units or (in the case of pure and const) if it cannot prove that the function returns normally. A function returns normally if it doesn't contain an infinite loop nor returns abnormally by throwing, calling abort() or trapping. This analysis requires option -fipa-pure-const, which is enabled by default at -O and higher. Higher optimization levels improve the accuracy of the analysis. 


I will have to test this:

>Virtual methods are considered for inlining when the caller is inlined and devirtualization is then possible.<

>Functions whose address was taken are now optimized out when all references to them are dead.<


This is sometimes useful in smaller systems, I think:

>A new switch -fstack-usage has been added. It makes the compiler output stack usage information for the program, on a per-function basis, in an auxiliary file.<


I don't undersatand why this is useful, why the compiler isn't able to infer this by itself:

>A new function attribute leaf was introduced. This attribute allows better inter-procedural optimization across calls to functions that return to the current unit only via returning or exception handling. This is the case for most library functions that have no callbacks.<


And I understand this even less:

>The new function attribute callee_pop_aggregate allows to specify if the caller or callee is responsible for popping the aggregate return pointer value from the stack.<


This is curious, in nothrow functions throws become halts:

>The new -fnothrow-opt flag changes the semantics of a throw() exception specification to match the proposed semantics of the noexcept specification: just call terminate if an exception tries to propagate out of a function with such an exception specification. This dramatically reduces or eliminates the code size overhead from adding the exception specification.<


This seems useful:

>The -Wshadow option now warns if a local variable or type declaration shadows another type in C++. Note that the compiler will not warn if a local variable shadows a struct/class/enum, but will warn if it shadows an explicit typedef.<

>When an identifier is not found in the current scope, G++ now offers suggestions about which identifier might have been intended.<


>Support for the Go programming language has been added to GCC. It is not enabled by default when you build GCC; use the --enable-languages configure option to build it.<


It seems GCC now supports the TBM (Trailing Bit Manipulation) instructions too:
http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01767.html

Bye,
bearophile


More information about the Digitalmars-d mailing list