This page is a "brief" summary of some of the huge number of improvementsin GCC 9.You may also want to check out ourPorting to GCC 9 page and thefull GCC documentation.
arm*-*-*),a bug in the implementation of the procedure call standard (AAPCS) in the GCC 6, 7 and 8 releases has been fixed: a structure containing a bit-field based on a 64-bit integral type and where no other element in a structure required 64-bit alignment could be passed incorrectly to functions. This is an ABI change. If the option-Wpsabi is enabled (on by default) the compiler will emit a diagnostic note for code that might be affected.Support for a number of older systems and recently unmaintained or untested target ports of GCC has been declared obsolete in GCC 9. Unless there is activity to revive them, the next release of GCC will have their sources permanentlyremoved.
The following ports for individual systems on particular architectures have been obsoleted:
*-*-solaris2.10). Details can be found in the announcement.spu*-*-*). Details can be found in the announcement.std::rotate algorithm in GCC 9.1.0 can cause ABI incompatibilities with object files compiled with other versions of GCC. If thestd::rotate algorithm is called with an empty range then it might cause a divide-by-zero error (as aSIGFPE signal) and crash. The change has been reverted for GCC 9.2.0 and future releases. For more details seeBug 90920. The problem can be avoided by recompiling any objects that might callstd::rotate with an empty range, so that the GCC 9.1.0 definition ofstd::rotate is not used.-frepo) has been deprecated and will be removed in a future release.--with-default-libstdcxx-abi=gcc4-compatible configure option is broken in the 9.1 and 9.2 releases, producing a shared library with missing symbols (seeBug 90361). As a workaround, configure without that option and build GCC as normal, then edit the installed<bits/c++config.h> headers to define the_GLIBCXX_USE_CXX11_ABI macro to0.The following GCC command line options have been introduced or improved.
kb andKiB,MB andMiB, orGB andGiB denoting the corresponding multiples of bytes. See Invoking GCC for more.-flive-patching=[inline-only-static|inline-clone] generates code suitable for live patching. At the same time it provides multiple-level control over IPA optimizations. See the user guide for more details.--completion, has been added to provide more fine option completion in a shell. It is intended to be used by Bash-completion.GCC's diagnostics now print source code with a left margin showing line numbers, configurable with-fno-diagnostics-show-line-numbers.
GCC's diagnostics can also now label regions of the source code to show pertinent information, such as the types within an expression.
$ g++ t.cct.cc: In function 'int test(const shape&, const shape&)':t.cc:15:4:error:no match for 'operator+' (operand types are 'boxed_value<double>' and 'boxed_value<double>') 14 | return (width(s1) * height(s1) |~~~~~~~~~~~~~~~~~~~~~~ || |boxed_value<[...]> 15 |+width(s2) * height(s2)); |^~~~~~~~~~~~~~~~~~~~~~~ || |boxed_value<[...]>
These labels can be disabled via-fno-diagnostics-show-labels.
-falign-functions,-falign-labels,-falign-loops, and-falign-jumps received support for a secondary alignment (e.g.-falign-loops=n:m:n2:m2).-fprofile-filter-files and-fprofile-exclude-files) has been added. The options help to filter which source files are instrumented.Numerous improvements have been made to the output of-fopt-info.
Messages are now prefixed withoptimized,missed, ornote, rather than the old behavior of all being prefixed withnote.
The output from-fopt-info can now contain information on inlining decisions:
$ g++ -c inline.cc -O2 -fopt-info-inline-allinline.cc:24:11: note: Considering inline candidate void foreach(T, T, void (*)(E)) [with T = char**; E = char*]/2.inline.cc:24:11: optimized: Inlining void foreach(T, T, void (*)(E)) [with T = char**; E = char*]/2 into int main(int, char**)/1.inline.cc:19:12: missed: not inlinable: void inline_me(char*)/0 -> int std::puts(const char*)/3, function body not availableinline.cc:13:8: optimized: Inlined void inline_me(char*)/4 into int main(int, char**)/1 which now has time 127.363637 and size 11, net change of +0.Unit growth for small function inlining: 16->16 (0%)Inlined 2 calls, eliminated 1 functions
The output from the vectorizer has been rationalized so that failed attempts to vectorize a loop are displayed in the form
[LOOP-LOCATION]: couldn't vectorize this loop [PROBLEM-LOCATION]: because of [REASON]
rather than an exhaustive log of all decisions made by the vectorizer. For example:
$ gcc -c v.c -O3 -fopt-info-all-vecv.c:7:3: missed: couldn't vectorize loopv.c:10:7: missed: statement clobbers memory: __asm__ __volatile__("" : : : "memory");v.c:3:6: note: vectorized 0 loops in function.v.c:10:7: missed: statement clobbers memory: __asm__ __volatile__("" : : : "memory"); The old behavior can be obtained via a new-internals suboption of-fopt-info.
SRCFILE.opt-record.json.gz file describing the optimization decisions made by GCC. This is similar to the output of-fopt-info, but with additional metadata such as the inlining chain, and profile information (if available).-fipa-stack-alignment.-fipa-reference-addressable.The following built-in functions have been introduced.
__builtin_expect_with_probability to provide branch prediction probability hints to the optimizer.__builtin_has_attribute determines whether a function, type, or variable has been declared with some attribute.__builtin_speculation_safe_value can be used to help mitigate against unsafe speculative execution.The following attributes have been introduced.
copy function attribute has been added. The attribute can also be applied to type definitions and to variable declarations.A large number of improvements to code generation have been made, including but not limited to the following.
-ftree-switch-conversion. For example:intfoo (int how){ switch (how) { case 2: how = 205; break; case 3: how = 305; break; case 4: how = 405; break; case 5: how = 505; break; case 6: how = 605; break; } return how;} can be transformed into100 * how + 5 (for values defined in the switch statement).max-inline-insns-small,max-inline-insns-size,uninlined-function-insns,uninlined-function-time,uninlined-thunk-insns, anduninlined-thunk-time were added.-fprofile-use now enables-fversion-loops-for-strides,-floop-interchange,-floop-unroll-and-jam,-ftree-loop-distribution.hot-bb-count-ws-permille was reduced from 999 to 990 to account for more precise histograms.--param lto-partitions) wasincreased from 32 to 128 enabling effective use of CPUs with more than32 hyperthreads.--param lto-max-streaming-parallelismcan now be used to control the number of streaming processes.-Wodr) arenow more informative and produce fewer redundant results.The following improvements to thegcov command-line utility have been made.
--use-hotness-colors (-q) that can provide perf-like coloring of hot functions.__builtin_convertvector built-in for vector conversions has been added.-Waddress-of-packed-member, enabled by default, warns about an unaligned pointer value from the address of a packed member of a struct or union.-Warray-bounds detects more instancesof out-of-bounds indices.-Wattribute-alias also detects attributemismatches between alias declarations and their targets, in additionto mismatches between their types.-Wformat-overflow and-Wformat-truncation have been extendedto all formatted input/output functions (where applicable) andenhanced to detect a subset of instances of reading past the endof unterminated constant character arrays in%sdirectives.-Wmissing-attributes detects instancesof missing function attributes on declarations of aliases and weakreferences.-Wstringop-truncation also detectsa subset of instances of reading past the end of unterminatedconstant character arrays,note.-std=c2x, to select support for the upcoming C2X revision of the ISO C standard. This standard is in the early stages of development and the only feature supported in GCC 9 is_Static_assert with a single argument (support for_Static_assert with two arguments was added in C11 and GCC 4.6). There are also new options-std=gnu2x, for C2X with GNU extensions, and-Wc11-c2x-compat, to warn for uses of features added in C2X (such warnings are also enabled by use of-Wpedantic if not using-std=c2x or-std=gnu2x).-Wabsolute-value warns for calls to standard functions that compute the absolute value of an argument when a more appropriate standard function is available. For example, callingabs(3.14) triggers the warning because the appropriate function to call to compute the absolute value of a double argument isfabs. The option also triggers warnings when the argument in a call to such a function has an unsigned type. This warning can be suppressed with an explicit type cast and it is also enabled by-Wextra.-Wdeprecated-copy, implied by-Wextra, warns about the C++11 deprecation of implicitly declared copy constructor and assignment operator if one of them is user-provided.-Wdeprecated-copy-dtor also warns if the destructor is user-provided, as specified in C++11.-Winit-list-lifetime, on by default, warns about uses ofstd::initializer_list that are likely to result in a dangling pointer, such as returning or assigning from a temporary list.-Wredundant-move, implied by-Wextra, warns about redundant calls tostd::move.-Wpessimizing-move, implied by-Wall, warns when a call tostd::move prevents copy elision.-Wclass-conversion, on by default, warns when a conversion function will never be called due to the type it converts to.-std=c++2a or-std=gnu++2a flags, including range-based for statements with initializer, default constructible and assignable stateless lambdas, lambdas in unevaluated contexts, language support for empty data members, allowing pack expansion in lambda init-capture, likely and unlikely attributes, class types in non-type template parameters, allowing virtual function calls in constant expressions, explicit(bool),std::is_constant_evaluated, nested inline namespaces, etc. For a full list of new features, seethe C++ status page.id-expression, andmem-initializer for longer. For example it is now able to pin-point the pertinent locations for bad initializations such as these$ g++ -c bad-inits.ccbad-inits.cc:10:14:error:cannot convert 'json' to 'int' in initialization 10 | { 3,json::object }, |~~~~~~^~~~~~ || |jsonbad-inits.cc:14:31:error:initializer-string for array of chars is too long [-fpermissive] 14 | char buffers[3][5] = { "red","green", "blue" }; |^~~~~~~bad-inits.cc: In constructor 'X::X()':bad-inits.cc:17:13:error:invalid conversion from 'int' to 'void*' [-fpermissive] 17 | X() : one(42), two(42), three(42) |^~ || |intrather than emitting the error at the final closing parenthesis or brace.
$ g++ param-type-mismatch.ccparam-type-mismatch.cc: In function 'int test(int, const char*, float)':param-type-mismatch.cc:8:32:error:cannot convert 'const char*' to 'const char**' 8 | return foo::member_1 (first,second, third); |^~~~~~ || |const char*param-type-mismatch.cc:3:46:note: initializing argument 2 of 'static int foo::member_1(int, const char**, float)' 3 | static int member_1 (int one,const char **two, float three); |~~~~~~~~~~~~~^~~highlights both the problematic argument, and the parameter that it can't be converted to.
$ g++ bad-conversion.ccbad-conversion.cc: In function 'void caller()':bad-conversion.cc:9:14:error:cannot convert 'bool' to 'void*' 9 | callee (0,false, 2); |^~~~~ || |boolbad-conversion.cc:3:19:note: initializing argument 2 of 'void callee(int, void*, int)' 3 | void callee (int,void *, int) |^~~~~~
$ g++ -c bad-printf.cc -Wallbad-printf.cc: In function 'void print_field(const char*, float, long int, long int)':bad-printf.cc:6:17:warning:field width specifier '*' expects argument of type 'int', but argument 3 has type 'long int' [-Wformat=] 6 | printf ("%s:%*ld ", fieldname,column - width, value); |~^~~~~~~~~~~~~~~~~ ||| |intlong intbad-printf.cc:6:19:warning:format '%ld' expects argument of type 'long int', but argument 4 has type 'double' [-Wformat=] 6 | printf ("%s:%*ld ", fieldname, column - width,value); |~~~^~~~~~ ||| |long intdouble |%*f
return *this; needed by various C++ operators:$ g++ -c operator.ccoperator.cc: In member function 'boxed_ptr& boxed_ptr::operator=(const boxed_ptr&)':operator.cc:7:3:warning:no return statement in function returning non-void [-Wreturn-type] 6 | m_ptr = other.m_ptr; +++ |+ return *this; 7 |} |^for when the compiler needs a
typename:$ g++ -c template.cctemplate.cc:3:3:error:need 'typename' before 'Traits::type' because 'Traits' is a dependent scope 3 |Traits::type type; |^~~~~~ |typenamewhen trying to use an accessor member as if it were a data member:
$ g++ -c fncall.ccfncall.cc: In function 'void hangman(const mystring&)':fncall.cc:12:11:error:invalid use of member function 'int mystring::get_length() const' (did you forget the '()' ?) 12 | if (str.get_length > 0) |~~~~^~~~~~~~~~ |()for C++11's scoped enums:
$ g++ -c enums.ccenums.cc: In function 'void json::test(const json::value&)':enums.cc:12:26:error:'STRING' was not declared in this scope; did you mean 'json::kind::STRING'? 12 | if (v.get_kind () ==STRING) |^~~~~~ |json::kind::STRINGenums.cc:3:44:note:'json::kind::STRING' declared here 3 | enum class kind { OBJECT, ARRAY, NUMBER,STRING, TRUE, FALSE, NULL_ }; |^~~~~~and a tweak to integrate the suggestions about misspelled members with that for accessors:
$ g++ -c accessor-fixit.ccaccessor-fixit.cc: In function 'int test(t*)':accessor-fixit.cc:17:15:error:'class t' has no member named 'ratio'; did you mean 'int t::m_ratio'? (accessible via 'int t::get_ratio() const') 17 | return ptr->ratio; |^~~~~ |get_ratio()In addition, various diagnostics in the C++ front-end have been streamlined by consolidating the suggestion into the initial error, rather than emitting a follow-up note:
$ g++ typo.cctypo.cc:5:13:error:'BUFSIZE' was not declared in this scope; did you mean 'BUF_SIZE'? 5 | uint8_t buf[BUFSIZE]; |^~~~~~~ |BUF_SIZE
<execution> (requiresThread Building Blocks 2018 or newer).<memory_resource>.<filesystem> does not require linking with-lstdc++fs now.std::remove_cvref,std::unwrap_reference,std::unwrap_decay_ref,std::is_nothrow_convertible, andstd::type_identity.<bit> and<version>.std::erase_if).contains member of maps and sets.starts_with,ends_with).std::midpoint andstd::lerp for interpolation.std::bind_front.std::visit<R>.std::assume_aligned.std::pmr::polymorphic_allocator<std::byte>.char8_t type.delete.std::is_constant_evaluated() function.BACK argument forMINLOC andMAXLOC has been implemented.FINDLOC intrinsic function has been implemented.IS_CONTIGUOUS intrinsic function has been implemented.c%re andc%im has been implemented.str%len anda%kind has been implemented.ISO_Fortran_binding.h source file have been implemented.MAX andMIN intrinsics are no longer guaranteed to return any particular value in case one of the arguments is aNaN. Note that this conforms to the Fortran standard and to what other Fortran compilers do. If there is a need to handle that case in some specific way, one needs to explicitly check forNaN's before callingMAX orMIN, e.g. by using theIEEE_IS_NAN function from the intrinsic moduleIEEE_ARITHMETIC.-fdec-include, set also by the-fdec option, has been added to increase compatibility with legacy code. With this option, anINCLUDE directive is also parsed as a statement, which allows the directive to be spread across multiple source lines with line continuations.BUILTIN directive, has been added. The purpose of the directive is to provide an API between the GCC compiler and the GNU C Library which would define vector implementations of math routines.cortex-a76).cortex-a76.cortex-a55).neoverse-n1).-mcpu or-mtune options, for example:-mcpu=cortex-a76 or-mtune=cortex-a76.cortex-a55 or as arguments to the equivalent target attributes and pragmas.The Armv8.3-A complex number instructions are now supported via intrinsics when the option-march=armv8.3-a or equivalent is specified. For the half-precision floating-point variants of these instructions use the architecture extension flag+fp16, e.g.-march=armv8.3-a+fp16.
The intrinsics are defined by the ACLE specification.
-march=armv8.5-a option.-march=armv8-a+sb option.-march=armv8-a+predres option.-march=armv8-a+ssbs option. This does not require a compiler option for Arm and thus-march=armv8-a+ssbs is an AArch64-specific option.-mcpu=neoverse-e1).-fstack-clash-protection option. The probing interval/guard size can be set by using--param stack-clash-protection-guard-size=12|16. The value of this parameter must be in bytes represented as a power of two. The two supported values for this parameter are 12 (for a 4KiB size, 2^12) and 16 (for a 64KiB size, 2^16). The default value is 16 (64Kb) and can be changed at configure time using the flag--with-stack-clash-protection-guard-size=12|16.-msign-return-address= has been deprecated. This has been replaced by the new-mbranch-protection= option. This new option can now be used to enable the return address signing as well as the new Branch Target Identification feature of Armv8.5-A architecture. For more information on the arguments accepted by this option, please refer toAArch64-Options.-march=armv8.5-a+rng option.-march=armv8.5-a+memtag option.-march values and the-mcpu options that used these architectures have been removed.-mcpu options.fiji).gfx900).-mlra.-mptwrite compiler switch.-march=cascadelake. The switch enables the following ISA extensions: AVX512F, AVX512VL, AVX512CD, AVX512BW, AVX512DQ, AVX512VNNI.loongson-mmi andloongson-ext extensions have been split fromloongson3a:loongson-mmi contains the Loongson MMI (MultiMedia extensions Instructions).loongson-ext contains the Loongson EXT (EXTensions instructions).loongson-ext2 contains the Loongson EXT2 instructions.-m[no-]loongson-mmi,-m[no-]loongson-ext, and-m[no-]loongson-ext2 enable or disable those extensions.gs464)which enablesloongson-mmi,loongson-ext by default.gs464e)which enablesloongson-mmi,loongson-ext,loongson-ext2 by default.gs264e)which enablesloongson-ext,loongson-ext2,msa by default.-mcpu and-mtune options (as in-mcpu=gs464 or-mtune=gs464e) or as arguments to the equivalent target attributes and pragmas.-march=arch13 option, the compiler will generate code making use of the new instructions introduced with the vector enhancement facility 2 and the miscellaneous instruction extension facility 2. The-mtune=arch13 option enables arch13 specific instruction scheduling without making use of new instructions.-mzvector option.-march=z14 or higher GCC emits alignments hints on the vector load/store instructions (8 or 16 byte).-mfentry is now supported. As well as the mcount mechanism the__fentry__ is called before the function prologue. However, since just a single instruction is required to call__fentry__ the call sequence imposes a smaller overhead than mcount (4 instructions). The produced code is compatible only with newer glibc versions, which provide the__fentry__ symbol and do not clobber r0 when resolving lazily bound functions.-mfentry is only supported when generating 64-bit code and does not work with nested C functions.-mnop-mcount option can be used to emit NOP instructions instead of an mcount or fentry call stub.-mrecord-mcount option a__mcount_loc section is generated containing pointers to each profiling call stub. This is useful for automatically patching in and out calls.g++ now unconditionally enables large file support when compiling 32-bit code.-mms-bitfields option is specified, or__attribute__((ms_struct)) is used-mhitachi option is specified, or__attribute__((renesas)) is usedauto_diagnostic_group. Such diagnostics will be nested by the output of-fdiagnostics-format=json.This is thelistof problem reports (PRs) from GCC's bug tracking system that areknown to be fixed in the 9.1 release. This list might not becomplete (that is, it is possible that some PRs that have been fixedare not listed here).
This is thelistof problem reports (PRs) from GCC's bug tracking system that areknown to be fixed in the 9.2 release. This list might not becomplete (that is, it is possible that some PRs that have been fixedare not listed here).
This is thelistof problem reports (PRs) from GCC's bug tracking system that areknown to be fixed in the 9.3 release. This list might not becomplete (that is, it is possible that some PRs that have been fixedare not listed here).
This is thelistof problem reports (PRs) from GCC's bug tracking system that areknown to be fixed in the 9.4 release. This list might not becomplete (that is, it is possible that some PRs that have been fixedare not listed here).
-moutline-atomics has been added to aid deployment of the Large System Extensions (LSE) on GNU/Linux systems built with a baseline architecture targeting Armv8-A. When the option is specified code is emitted to detect the presence of LSE instructions at run time and use them for standard atomic operations. For more information please refer to the documentation.-mcpu and-mtune options are-mcpu=a64fx and-mtune=a64fx respectively. In particular,-mcpu=a64fx generates code for Armv8.2-A with SVE and tunes the code for the A64FX. This includes tuning the SVE code, although by default the code is still length-agnostic and so works for all SVE implementations. Adding-msve-vector-bits=512 makes the code specific to 512-bit SVE.This is thelistof problem reports (PRs) from GCC's bug tracking system that areknown to be fixed in the 9.5 release. This list might not becomplete (that is, it is possible that some PRs that have been fixedare not listed here).
Copyright (C)Free Software Foundation, Inc.Verbatim copying and distribution of this entire article ispermitted in any medium, provided this notice is preserved.
These pages aremaintained by the GCC team.Last modified 2025-01-31.