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.
Note: GCC 11 has not been released yet, so this document is a work-in-progress.
-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. --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.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
).-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.
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.
-Wtsan
, enabled by default,
warns about unsupported features in ThreadSanitizer (currently std::atomic_thread_fence
).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.gcov
tool have been renamed: -i
to -j
and -j
to -H
.-std=gnu++17
.consteval virtual
functionsusing enum
-fmodules-ts
and some aspects
are incomplete. Refer
to C++ 20 Status
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].
-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.
std::from_chars
for floating-point types.<chrono>
.std::bit_cast
std::source_location
<barrier>
, <latch>
,
and <semaphore>
<syncstream>
basic_stringbuf
's buffer.std::uniform_int_distribution
,
thanks to Daniel Lemire.
DEPRECATED
to !GCC$
's
attributes
directive.
asm
in the C front end-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.
-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, GCC will by
default match the definition of float_t
in the installed
glibc.
malloc
/free
checking within
-fanalyzer
has been generalized to also check new
/delete
and new[]
/delete[]
, adding a new
-Wanalyzer-mismatching-deallocation
warning. However, C++ is not yet properly supported by
-fanalyzer
(for example, exception-handling is unimplemented).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 2021-01-18.