This page is a "brief" summary of some of the huge number of improvements in GCC 11. You may also want to check out our Porting to GCC 11 page and the full GCC documentation.
-std=gnu++17
instead of
-std=gnu++14
. Note
that C++17 changes to template
template parameter matching can be disabled independently of other
features with -fno-new-ttp-matching
.
-dumpbase
,
-dumpdir
, -save-temps=*
, and you expect
any file other than the
primary output file(s) to be created as a side effect, watch out
for improvements and a few surprises.
See the
patch, particularly its textual description, for more
details about the changes.-gsplit-dwarf
no longer enables debug info generation
on its own but requires a separate -g
for this.--enable-cheaders=c_std
is deprecated and will be removed in a future release. It should be
possible to use --enable-cheaders=c_global
(the default)
with no change in behaviour. gcov
tool have been renamed: -i
to -j
and -j
to -H
.--param tsan-distinguish-volatile
to optionally emit
instrumentation distinguishing volatile accesses.--param tsan-instrument-func-entry-exit
to optionally
control if function entries and exits should be instrumented.In previous releases of GCC, the "column numbers" emitted in diagnostics were actually a count of bytes from the start of the source line. This could be problematic, both because of:
For example, the character π ("GREEK SMALL LETTER PI (U+03C0)") occupies one column, and its UTF-8 encoding requires two bytes; the character 🙂 ("SLIGHTLY SMILING FACE (U+1F642)") occupies two columns, and its UTF-8 encoding requires four bytes.
In GCC 11 the column numbers default to being column numbers, respecting
multi-column characters. The old behavior can be restored using a new
option
-fdiagnostics-column-unit=byte
.
There is also a new option
-fdiagnostics-column-origin=
,
allowing the pre-existing default of the left-hand column being column
1 to be overridden if desired (e.g. for 0-based columns). The output
of
-fdiagnostics-format=json
has been extended to supply both byte counts and column numbers for all source locations.
Additionally, in previous releases of GCC, tab characters in the source
would be emitted verbatim when quoting source code, but be prefixed
with whitespace or line number information, leading to misalignments
in the resulting output when compared with the actual source. Tab
characters are now printed as an appropriate number of spaces, using the
-ftabstop
option (which defaults to 8 spaces per tab stop).
Introduce Hardware-assisted AddressSanitizer support. This sanitizer currently only works for the AArch64 target. It helps debug address problems similarly to AddressSanitizer but is based on partial hardware assistance and provides probabilistic protection to use less RAM at run time. Hardware-assisted AddressSanitizer is not production-ready for user space, and is provided mainly for use compiling the Linux Kernel.
To use this sanitizer the command line arguments are:-fsanitize=hwaddress
to instrument userspace code.-fsanitize=kernel-hwaddress
to instrument kernel code.For targets that produce DWARF debugging information GCC now defaults to DWARF version 5 (with the exception of VxWorks and Darwin/Mac OS X which default to version 2 and AIX which defaults to version 4). This can produce up to 25% more compact debug information compared to earlier versions.
To take full advantage of DWARF version 5 GCC needs to be built
against binutils version 2.35.2 or higher. When GCC is built
against earlier versions of binutils GCC will still emit DWARF
version 5 for most debuginfo data, but will generate version 4
debug line tables (even when explicitly given -gdwarf-5
).
The following debug information consumers can process DWARF version 5:
Programs embedding libbacktrace are urged to upgrade to the version shipping with GCC 11.
To make GCC 11 generate an older DWARF version
use -g
together with -gdwarf-2
,
-gdwarf-3
or -gdwarf-4
.
int IsHTMLWhitespace(int aChar) { return aChar == 0x0009 || aChar == 0x000A || aChar == 0x000C || aChar == 0x000D || aChar == 0x0020; }This statement can be transformed into a switch statement and then expanded into a bit-test.
-fbit-tests
, enabled by default, can be used to enable or disable switch expansion using bit-tests.-fipa-modref
option.
-fipa-icf
)
was significantly improved to increase the number of
unified functions and to reduce compile-time memory use.-fprofile-values
,
was improved by tracking more target values for e.g. indirect calls.
allocate
clause support in C/C++.
The OMP_TARGET_OFFLOAD
environment variable and the
active-levels routines are now supported.
For C/C++, the declare variant
and map
support has been extended.
For Fortran, OpenMP 4.5 is now fully supported and OpenMP 5.0
support has been extended, including the following features which were
before only available in C and C++: order(concurrent)
,
device_type
, memorder-clauses for flush
,
lastprivate
with conditional
modifier,
atomic
construct and reduction
clause
extensions of OpenMP 5.0,
if
clause with simd
and cancel
modifiers, target data
without map
clause,
and limited support for the requires
construct.
no_stack_protector
attribute has been added to mark functions which should not be instrumented
with stack protection (-fstack-protector
).malloc
attribute has been extended so that it can be used to identify
allocator/deallocator API pairs. A pair of new
-Wmismatched-dealloc
and -Wmismatched-new-delete
warnings will complain
about mismatched calls, and -Wfree-nonheap-object
about deallocation calls with pointers not obtained from allocation
functions. Additionally, the static analyzer will use these
attributes when checking for leaks, double-frees, use-after-frees,
and similar issues.
-Wmismatched-dealloc
,
enabled by default, warns about calls to deallocation functions
with pointers returned from mismatched allocation functions.
-Wsizeof-array-div
,
enabled by -Wall
, warns
about divisions of two sizeof operators when the first one is applied
to an array and the divisor does not equal the size of the array
element.
-Wstringop-overread
,
enabled by default, warns about calls to string functions reading
past the end of the arrays passed to them as arguments. In prior
GCC releases most instances of his warning are diagnosed by
-Wstringop-overflow
.
-Wtsan
,
enabled by default, warns about unsupported features in ThreadSanitizer
(currently std::atomic_thread_fence
).
-Wfree-nonheap-object
detects many more instances of calls to deallocation functions with
pointers not returned from a dynamic memory allocation function.
-Wmaybe-uninitialized
diagnoses passing pointers or references to uninitialized memory
to functions taking const
-qualified arguments.
-Wuninitialized
detects reads from uninitialized dynamically allocated memory.
For ELF targets that support the GNU or FreeBSD OSABIs, the
used
attribute will now save the symbol declaration it is
applied to from linker garbage collection.
To support this behavior, used
symbols that have not
been placed in specific sections (e.g. with the section
attribute, or the -f{function,data}-sections
options) will
be placed in new, unique sections.
This functionality requires Binutils version 2.36 or later.
-std=c2x
and -std=gnu2x
. Some of these features are also
supported as extensions when compiling for older language versions.
In addition to the features listed, some features previously
supported as extensions and now added to the C standard are enabled
by default in C2X mode and not diagnosed with -std=c2x
-Wpedantic
.
BOOL_MAX
and BOOL_WIDTH
macros
are provided in <limits.h>
.true
and false
macros in <stdbool.h>
have changed so that they
have type bool
.[[nodiscard]]
standard attribute is now
supported.__has_c_attribute
preprocessor operator is
now supported.INFINITY
, NAN
, FLT_SNAN
,
DBL_SNAN
, LDBL_SNAN
, DEC_INFINITY
,
DEC_NAN
, and corresponding signaling NaN macros for
_FloatN
, _FloatNx
and _DecimalN
types, are provided
in <float.h>
. There are also corresponding
built-in functions __builtin_nansdN
for
decimal signaling NaNs.FLT_IS_IEC_60559
, DBL_IS_IEC_60559
and LDBL_IS_IEC_60559
are provided
in <float.h>
.__STDC_WANT_IEC_60559_EXT__
is supported
by <float.h>
.-Warray-parameter
,
enabled by -Wall
, warns about redeclarations of functions
with ordinary array arguments declared using inconsistent forms.
The warning also enables the detection of the likely out of bounds
accesses in calls to such functions with smaller arrays.
-Wvla-parameter
,
enabled by -Wall
, warns redeclarations of functions
with variable length array arguments declared using inconsistent
forms or with mismatched bounds. The warning also enables
the detection of the likely out of bounds accesses in calls to
such functions with smaller arrays.
-std=gnu++17
.consteval virtual
functionsusing enum
-fmodules-ts
and some aspects
are incomplete. Refer
to C++ 20 Status
-std=c++23
, -std=gnu++23
,
-std=c++2b
or -std=gnu++2b
flags,
including
auto
as a template-argumentnoexcept
?reinterpret_cast
s in constexpr evaluation are now checked
more completely (PR95307).static_assert
has been improved: the
compiler now shows the expression including its template arguments (if
there were any), and can point to the failing clause if the condition
comprised of any logical AND operators
(PR97518).-Wctad-maybe-unsupported
,
disabled by default, warns
about performing class template argument deduction on a type with no
deduction guides.
-Wrange-loop-construct
,
enabled by -Wall
,
warns when a range-based for-loop is creating unnecessary and
expensive copies.
-Wdeprecated-enum-enum-conversion
,
enabled by default in
C++20, warns about deprecated arithmetic conversions on operands of
enumeration types, as outlined in [depr.arith.conv.enum].
-Wdeprecated-enum-float-conversion
,
enabled by default in
C++20, warns about deprecated arithmetic conversions on operands where
one is of enumeration type and the other is of a floating-point type,
as outlined in [depr.arith.conv.enum].
-Wmismatched-new-delete
,
enabled by -Wall
, warns about calls to C++
operator delete
with pointers returned from mismatched
forms of operator new
or from other mismatched allocation
functions.
-Wvexing-parse
,
enabled by default, warns about the most
vexing parse rule: the cases when a declaration looks like a variable
definition, but the C++ language requires it to be interpreted as a
function declaration.
-Wnonnull
considers the implicit this
argument of every C++
nonstatic member function to have been implicitly declared with
attribute nonnull
and triggers warnings for calls where
the pointer is null.
std::from_chars
and std::to_chars
for floating-point types.<chrono>
.
Thanks to Cassio Neri for optimizations.
std::bit_cast
std::source_location
<barrier>
, <latch>
,
and <semaphore>
<syncstream>
basic_stringbuf
's buffer.contains
member functions for strings,
thanks to Paul Fee.
std::to_underlying
, std::is_scoped_enum
simd
)
from the Parallelism 2 TS, thanks to Matthias Kretz.
std::uniform_int_distribution
,
thanks to Daniel Lemire.
typeof(*null)
has been added to
represent run-time errors and non-terminating functions. This also
introduces a new standard alias for the type named
noreturn
, and is implicitly imported into every module.
pragma(printf)
for printf-like functions or
pragma(scanf)
for scanf-like functions.
__traits()
expression now supports the extensions
isDeprecated
, isDisabled
,
isFuture
, isModule
, isPackage
,
child
, isReturnOnStack
,
isZeroInit
, getTargetInfo
,
getLocation
, hasPostblit
,
isCopyable
, getVisibility
, and
totype
.
ref
keyword.
alias
syntax based on the assignment operator.
__c_complex_float
,
__c_complex_double
, __c_complex_real
, and
__c_wchar_t
have been added for interfacing with C
and C++ code, and are available from the core.stdc.config
module.
int
or void function()
.
mixin
construct can now be used as types in the form
mixin(string) var
.
mixin
construct can now take an argument list, same
as pragma(msg)
.
core.bitop.rol
and
core.bitop.ror
have been added.
core.bitop.byteswap
for swapping
bytes in a 2-byte ushort
has been added.
core.math
now have
overloads for float
and double
types.
core.volatile.volatileLoad
and
core.volatile.volatileStore
have been moved from the
core.bitop
module.
gcc.attributes
module with short-hand aliases for
convenience:
@attribute("alloc_size", arguments)
or
@alloc_size(arguments)
.
@attribute("always_inline")
or
@always_inline
.
@attribute("used")
or @used
.@attribute("optimize", arguments)
or
@optimize(arguments)
.
@attribute("cold")
or @cold
.@attribute("noplt")
or @noplt
.@attribute("target_clones", arguments)
or
@target_clones(arguments)
.
@attribute("no_icf")
or @no_icf
.@attribute("noipa")
or @noipa
.@attribute("symver", arguments)
or
@symver(arguments)
.
gcc.attributes
for
compatibility with ldc.attributes
.
@allocSize(arguments)
attribute is the same as
@alloc_size(arguments)
, but uses a 0-based index for
function arguments.
@assumeUsed
attribute is an alias for
@attribute("used")
.
@fastmath
attribute is an alias for
@optimize("Ofast")
.
@naked
attribute is an alias for
@attribute("naked")
. This attribute may not be
available on all targets.
@restrict
attribute has been added to specify
that a function parameter is to be restrict-qualified in the C99
sense of the term.
@optStrategy(strategy)
attribute is an alias for
@optimize("O0")
when the strategy
is
"none"
, otherwise @optimize("Os")
for the
"optsize"
and "minsize"
strategies.
@polly
attribute is an alias for
@optimize("loop-parallelize-all")
.
@section(name)
attribute is an alias for
@attribute("section", name)
.
@target(arguments)
attribute is an alias for
attribute("target", arguments)
.
@weak
attribute is an alias for
@attribute("weak")
.
-fweak-templates
, added to control whether declarations
that can be defined in multiple objects should be emitted as weak
symbols. The default is to emit all symbols with extern linkage as
weak, unless the target lacks support for weak symbols.
-Wdeprecated
, this option is now enabled by default.
-Wextra
, this option now turns on all warnings that are
not part of the core D language front-end - -Waddress
,
-Wcast-result
, -Wunknown-pragmas
.
-Wvarargs
, added to turn on warnings about questionable
usage of the va_start
intrinsic.
gcc.attributes
module, the former module
gcc.attribute
has been deprecated and will be removed in
a future release.
@attribute("alias")
attribute has been removed, as
it had been superseded by pragma(mangle)
.
@attribute("forceinline")
attribute has been removed
and renamed to @always_inline
.
__vector
types that are not supported in hardware are
now rejected at compile-time. Previously all vector types were
accepted by the compiler and emulated when target support was absent.
extern(Pascal)
linkage attribute has been removed.
-ftransition=import
and
-ftransition=checkimports
is finished. These switches no
longer have an effect and are now removed. Symbols that are not
visible in a particular scope will no longer be found by the compiler.
-fweak
compiler switch has been removed, as it
existed only for testing.
DEPRECATED
to !GCC$
's
attributes
directive.
gcc_jit_global_set_initializer
asm
in the C front end-mcpu
and -mtune
options in both
the arm and aarch64 back ends (GCC identifiers in parentheses):
cortex-a78
).cortex-a78ae
).cortex-a78c
).cortex-x1
).neoverse-v1
).neoverse-n2
).a64fx
).cortex-r82
).-march=armv8-r
option.-mharden-sls=
option. Please refer to the
documentation for usage instructions.arm_neon.h
header is improved and GCC 11 supports the full
set of intrinsics defined by ACLE Q3 2020.gfx908
GPUs has been added.-mcpu=cortex-m55
option now supports the extensions
+nomve
and +nomve.fp
to control generation of
MVE and MVE floating-point instructions.-mtsxldtrk
compiler switch.
-mserialize
compiler switch.
-mhreset
compiler switch.
-muintr
compiler switch.
-mkeylocker
compiler switch.
-mamx-tile, -mamx-int8, -mamx-bf16
compiler
switches.
-mavxvnni
compiler switch.
-march=sapphirerapids
.
The switch enables the MOVDIRI, MOVDIR64B, AVX512VP2INTERSECT, ENQCMD,
CLDEMOTE, SERIALIZE, PTWRITE, WAITPKG, TSXLDTRK, AMT-TILE, AMX-INT8,
AMX-BF16, and AVX-VNNI ISA extensions.
-march=alderlake
.
The switch enables the CLDEMOTE, PTWRITE, WAITPKG, SERIALIZE, KEYLOCKER,
AVX-VNNI, and HRESET ISA extensions.
-march=rocketlake
.
Rocket Lake is based on Icelake client and minus SGX.
znver3
core
via -march=znver3
.
-march=x86-64-v2
, -march=x86-64-v3
and
-march=x86-64-v4
.
-mcustom-insn=N
no longer produce compiler
warnings if the custom instruction is not generated due to missing
optimization options such as -fno-math-errno
,
-ffinite-math-only
, or
-funsafe-math-optimizations
. These warnings were not
consistently emitted for all custom instructions.
-mcustom-fpu-cfg=fph2
option has been added to enable
the custom instructions supported by the Nios II Floating Point
Hardware 2 Component.
-misa
default has changed from sm_30
to sm_35
.
-m32
compiler switch has been removed.
-msoft-stack-reserve-local
format has been fixed.
Previously, it accepted -msoft-stack-reserve-local<n>
.
It now accepts -msoft-stack-reserve-local=<n>
.
-fexcess-precision=standard
(e.g., implied by -std=c99
) on s390(x) targets can now be
controlled at configure time with the flag
--enable-s390-excess-float-precision
. When enabled, GCC will
maintain previous behavior and evaluate float expressions in double
precision, which aligns with the definition of float_t
as
double
. With the flag disabled, GCC will always evaluate
float expressions in single precision. In native builds and cross compiles
that have target libc headers, GCC will by default match the definition of
float_t
in the installed glibc.
__riscv_atomic
are deprecated, but will still be
supported for at least 2 release cycles.
riscv*-*-linux*
.-misa-spec=*
to control ISA spec version.
This controls the default version of each extensions.
It defaults to 2.2.--with-multilib-generator
configure time
option.
This allows for flexible config multi-lib settings. Its syntax is
the same as RISC-V's multilib-generator
.
multilib-generator
, support expansion
operator *
to reduce the complexity of complicated multi-lib
re-use rules.
-mcpu=*
option aligned with RISC-V clang/LLVM.
It sets the pipeline model and architecture extensions, like
-mtune=*
plus -march=*
.
__builtin_thread_pointer
for RISC-V.shorten_memrefs
optimization, which reduces
the code size for memory access, thanks to Craig Blackmore.
malloc
and free
.
malloc
/free
checking will also
check new
/delete
and new[]
/delete[]
.
However, C++ is not yet properly supported by
-fanalyzer
(for example, exception-handling is unimplemented).
malloc
attribute has been extended so that it can be used to identify
allocator/deallocator API pairs. The analyzer will use these
attributes when checking for leaks, double-frees, use-after-frees, and
similar issues.
-Wanalyzer-mismatching-deallocation
warning has been added, covering such mismatches as using
scalar delete
rather vector delete[]
.
-Wanalyzer-shift-count-negative
,
-Wanalyzer-shift-count-overflow
,
-Wanalyzer-write-to-const
, and
-Wanalyzer-write-to-string-literal
,
all enabled by default when
-fanalyzer
is enabled.
-fdump-analyzer-json
and
-fno-analyzer-feasibility
.
GCC_EXTRA_DIAGNOSTIC_OUTPUT
which can be used by IDEs to request machine-readable fix-it hints
without needing to adjust build flags.
This is the list of problem reports (PRs) from GCC's bug tracking system that are known to be fixed in the 11.1 release. This list might not be complete (that is, it is possible that some PRs that have been fixed are not listed here).
This is the list of problem reports (PRs) from GCC's bug tracking system that are known to be fixed in the 11.2 release. This list might not be complete (that is, it is possible that some PRs that have been fixed are not listed here).
This is the list of problem reports (PRs) from GCC's bug tracking system that are known to be fixed in the 11.3 release. This list might not be complete (that is, it is possible that some PRs that have been fixed are not listed here).
This is the list of problem reports (PRs) from GCC's bug tracking system that are known to be fixed in the 11.4 release. This list might not be complete (that is, it is possible that some PRs that have been fixed are not listed here).
-Wpsabi
.
-mharden-sls=[none|all|return|indirect-jmp]
.
-mindirect-branch-cs-prefix
.
This is the list of problem reports (PRs) from GCC's bug tracking system that are known to be fixed in the 11.5 release. This list might not be complete (that is, it is possible that some PRs that have been fixed are not listed here).
--with-arch=
, --with=cpu=
and/or
--with-tune=
configure options the compiler without
explicit -march=
etc. options might act as if asked
for cortex-a34
. This can be fixed by applying manually the
r12-8060 commit patch on top
of GCC 11.5.0. See PR116029
for more details. GCC 11.4.0 or earlier releases are not affected.
Copyright (C) Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.
These pages are maintained by the GCC team. Last modified 2024-07-23.