GCC 16 Release Series
Changes, New Features, and Fixes
This page is a "brief" summary of some of the huge number of improvements in GCC 16. You may also want to check out our Porting to GCC 16 page and the full GCC documentation.
Caveats
int8_tetc. are nowsigned charon Solaris for conformance with the C99 standard. However, this is an incompatible change. See the porting notes for more information.- The
-pthreadoption no longer predefines_REENTRANTon Solaris. See the porting notes for more information. - The so-called "
json" format for-fdiagnostics-format=has been removed in this release. Users seeking machine-readable diagnostics from GCC should use SARIF. - In the AArch64 port, support for PC relative literal loads (-mpc-relative-literal-loads) has been deprecated with the improvements in usages of constant anchors. The option will be removed in a future version.
General Improvements
- Link-Time Optimization now supports better handling of toplevel asm
statements with
-flto-toplevel-asm-heuristics. - Speculative devirtualization now handles general indirect function calls and supports speculating of more than one target.
- The vectorizer is now more flexible in identifying in-loop parallelism of reductions.
- The vectorizer now supports vectorizing uncounted loops or loops for which the number of iterations could not be determined.
- The vectorizer now supports peeling for alignment for vector length agnostic loops using masking.
- The vectorizer now supports mutual peeling for alignment.
- The vectorizer now generates more efficient code for loops with early breaks by eliminating the vector induction computations.
Documentation
- The documentation for GCC Command Options and the option index have been corrected to include many previously missing options.
- The documentation for GCC-specific attributes has been modernized to put more emphasis on the standard attribute syntax, which GCC accepts in all supported dialects of C and C++. The material has also been reorganized to be less repetitive, and there is a new index for attributes.
- Documentation for parameters and option spec files has been moved from the main GCC manual to the GCC internals manual. These features are intended for use by GCC developers and those who need to build custom GCC configurations.
New Languages and Language specific improvements
OpenMP
See the GNU Offloading and Multi-Processing Project (GOMP) page for general information.
- The
memory allocation support has been enhanced: for allocators with the
pinnedtrait, includingompx_gnu_pinned_mem_alloc, the CUDA API (if available) is used; this improves the performance when accessing this memory on Nvidia GPUs. The newly addedompx_gnu_managed_mem_allocallocator and theompx_gnu_managed_mem_space(both GNU extensions) allocate device-accessible memory on the host. Such memory is device accessible even when unified-shared memory is not supported and might have different page-migration behavior than other memory on systems even if all host memory is device accessible. - OpenMP 5.0: Limited support for
declare mapperhas been added for C and C++, only. Theuses_allocatorsclause is now supported, including the OpenMP 5.2 syntax changes and supporting semicolons (OpenMP 6.0); for now, only predefined allocators are supported. - OpenMP 5.1: Initial support for the
iteratormodifier in map clauses and thetarget updateconstruct has been added for C and C++. - OpenMP 5.2: The
begin declare variantdirective for C and C++ is now supported. - OpenMP 6.0: The
omp_target_memsetandomp_target_memset_asyncAPI routines have been added. Theno_openmp_constructsassumptions clause can now be used. - OpenMP Technical Report 14 (TR14): The named
omp_default_deviceconstant has been added to denote the default-device number. - For OpenMP directives and clauses that have been deprecated in OpenMP 5.0,
5.1, or 5.2, a deprecation warning is shown, hinting at the to-be-used
syntax; the warning is on by default and can be silenced using
-Wno-deprecated-openmp. Additionally, a deprecation warning is shown when using a deprecated named constant or API routine; this warning can be silenced using-Wno-deprecated-declarations.
OpenACC
See the GCC OpenACC wiki page for general information.
- The
acc_memcpy_deviceandacc_memcpy_device_asyncAPI routines have been added for C, C++ and Fortran. - OpenACC 3.0: The
waitdirective now accepts theifclause. - OpenACC 3.3: The Fortran API routines
acc_attachandacc_detachnow augment their OpenACC 2.6 C/C++ counterparts. - OpenACC 3.4: In Fortran, named constants (
PARAMETER) used as var in data clauses are now permitted by the specification and GCC for better compatibility with existing code; however, with GCC, specifying them in data clauses affects neither compile-time nor runtime behavior.
Ada
GNAT Extensions
- The Constructor [RFC] and Destructor [RFC] extensions add new construction/finalization mechanisms that differ significantly from standard Ada. Those features are inspired by object-oriented programming in other widely used languages (such as C++).
- Implicit with allows a stand-alone use clause in the context clause of a compilation unit to imply an implicit with of the same library unit where an equivalent with clause would be allowed.
- Structural Generic instantiation [RFC] allows reference to an implicit instance of a generic unit, that is denoted directly by the unit’s name and actual parameters, rather than by a separately declared name.
- The Extended_Access aspect can be specified on a general access type declaration designating an unconstrained array subtype. It changes the pointer representation and allows easier interfacing with foreign languages when memory for the designated object is not allocated by Ada. In particular, it allows the creation of access to an array slice [RFC].
Other
-
VAST (Verifier for the Ada Semantic Tree), enabled
with
-gnatd_V(or-gnatd_Wfor verbose mode), can be used to debug the compiler. It checks various properties of the produced Ada Semantic Tree and reports detected violations. - The semantic analysis of Ada 2022’s Reduction Expressions has been enhanced.
- The Ada.Containers.Bounded_Indefinite_Holders unit has been added.
- Various loopholes in the implementation of accessibility rules have been plugged.
- Android support has been improved.
C++
- C++20 by default: GCC 16 changes the default language version for C++ compilation from -std=gnu++17 to -std=gnu++20. If your code relies on older versions of the C++ standard, you will need to either add -std= to your build flags, or port your code; see the porting notes. N.B. C++20 modules support is still experimental and must be enabled by -fmodules.
- Several C++26 features have been implemented:
- P2996R13, Reflection
(PR120775, enabled by
-std=c++26 -freflection) - P3394R4, Annotations for Reflection
- P3293R3, Splicing a base class subobject
- P3096R12, Function Parameter Reflection
- P3491R3,
define_static_{string,object,array} (PR120783) - P3560R2, Error Handling in Reflection
- P1306R5, Expansion statements (PR120776)
- P2900R14, Contracts (PR119061)
- P2795R5, Erroneous behavior for uninitialized reads (PR114457)
- P1061R10, Structured bindings can introduce a pack (PR117783)
- P3068R5,
constexprexceptions (PR117785) - P3533R2,
constexprvirtual inheritance (PR120777) - P1494R5, Partial program correctness (PR119060)
- P3618R0, Allow attaching main to the global module (PR120773)
- P2843R3, Preprocessing is never undefined (PR120778)
- P2686R4,
constexprstructured bindings and references toconstexprvariables (PR117784, only partially, structured bindings can beconstexprbut references toconstexprautomatic variables still not allowed)
- P2996R13, Reflection
(PR120775, enabled by
- Several C++23 features have been implemented:
- Various C++ error messages (such as for problems involving templates)
now have a hierarchical structure. This nesting of messages is presented
using indentation and bullet points. The old behavior can be restored via
-fno-diagnostics-show-nestingor-fdiagnostics-plain-output. - Improved experimental C++20 modules support:
-
New command line option
--compile-std-modulethat conveniently builds the<bits/stdc++.h>header unit and thestdandstd.compatmodules before compiling any source files explicitly specified on the command line. -
Whenever the
<bits/stdc++.h>header unit has been built, GCC now transparently translates an#includeof any importable standard library header into animportof<bits/stdc++.h>. - Many reported bugs have been fixed, thanks to Nathaniel Shead.
-
New command line option
-
Constraint failure diagnostics for standard library type traits such as
is_constructible_vandis_invocable_vare improved to further elaborate why the trait isfalseinstead of just reportingexpression is_foo_v<...> evaluated to false, thanks to Nathaniel Shead.
Runtime Library (libstdc++)
-
For targets that support
128-bit
integers,
std::is_integral<__int128>and similar traits are always true. Previously this was only the case when compiling with GNU dialects (-std=gnu++17,-std=gnu++14, etc.) and not with strict dialects (-std=c++17, etc.) -
The proposal
P0952R2: A new specification for
std::generate_canonicalwas implemented in all affected modes (since C++11), impacting the observed output. The previous behavior can be restored by defining_GLIBCXX_USE_OLD_GENERATE_CANONICAL. -
The
std::variantABI was updated to make it conforming and consistent with C++20 and later modes. This impacts the layout of classes which have astd::variantas the first member and a base class of the same type as one of thevariant'salternatives, if that type is an empty class and has a non-trivial destructor:struct E { ~E(); }; struct Affected : E { std::variant<E, int> mem; // previously stored at offset zero, // uses non-zero offset now };The previous behavior can be restored by defining_GLIBCXX_USE_VARIANT_CXX17_OLD_ABI. This impacts only C++17 mode. -
std::regexexecution has been rewritten to use a heap-based stack instead of the system stack, avoiding stack overflows when matching larger strings. - Improved support for C++20, including:
- The C++20 implementation is no longer experimental.
-
Working
std::chrono::current_zone()on Windows (thanks to Björn Schäpers).
-
There are several changes to C++20 components which are incompatible with
the experimental C++20 support in previous releases. The following C++20
components have ABI changes in GCC 16:
-
Atomic waiting/notifying functions in
<atomic>and semaphore types in<semaphore>. Synchronization for<syncstream>. -
The representation of
std::formatargs andstd::formatterspecializations. -
The representation of the
std::partial_orderingtype in<compare>. -
Semantics of
std::variantwithstd::jthread,std::stop_token, andstd::stop_sourcealternatives. -
Representation of some range adaptors in
<ranges>.
-
Atomic waiting/notifying functions in
- Improved experimental support for C++23, including:
std::mdspan, thanks to Luc Grosheintz.-
ranges::starts_withandranges::ends_with. -
ranges::shift_leftandranges::shift_right. std::allocator_traits::allocate_at_least.
- Improved experimental support for C++26, including:
std::simd.std::inplace_vector.std::optional<T&>.-
std::copyable_functionandstd::function_ref. std::indirectandstd::polymorphic.-
std::owner_equalfor shared pointers, thanks to Paul Keir. <debugging>header and contents.- New
std::stringstreamandstd::bitsetmember functions acceptingstd::string_viewarguments, thanks to Nathan Myers. -
Padded mdspan layouts, aligned accessor,
std::dims,std::constant_wrapper, andstd::submdspanthanks to Luc Grosheintz. std::philox_engine, thanks to 1nfocalypse.std::atomic_ref::address(), thanks to Yuao Ma.
Fortran
- Coarrays using native shared memory mulithreading on single node
machines and handling Fortran 2018's
TEAMfeature. - Fortran 2003: Parameterized Derived Types support is improved. Handling of LEN parameters works but still requires a future change of representation (see PR82649).
- Fortran 2018: Support the extensions to the
IMPORTstatement, theREDUCEintrinsic and the newGENERICstatement. - The Fortran 2023 additions to the trigonometric functions are now
supported (such as the
sinpiintrinsic). - Fortran 2023: The
splitintrinsic subroutine is now supported andc_f_pointernow accepts an optional lower bound as a argument. - The
-fexternal-blas64option has been added to call external BLAS routines with 64-bit integer arguments forMATMUL. This option is only valid for 64-bit systems and when-ffrontend-optimizeis in effect.
Modula-2
- Spelling hints have been implemented. Currently spelling hints are issued when processing: import lists, module names and all symbols within nested scopes.
- A new implementation of wide set is used and this is
accompanied with a library module
M2WIDESET. This has changed the ABI and may lead to link-time errors with object files generated with a previous GCC version. - A binary dictionary module
BinDicthas been added to the base libraries. - The procedures
WriteandWriteLnare available in the modules:ARRAYOFCHAR,CFileSysOp,CHAR,FileSysOp,StringandStringFileSysOp. - The
-fm2-pathname-root=option has been added to improve access to external library modules.
Algol 68
- GCC now includes an experimental Algol 68 compiler, ga68. It aims to
implement the language described by the Revised Report, including all
errata approved by the Algol 68 Support subcommittee of IFIP WG2.1.
Some GNU extensions and a POSIX prelude are also implemented.
More information about the language can be found on the Algol 68 website.
More information about the front end can be found on the wiki.
New Targets and Target Specific Improvements
AArch64
- As noted above, support for PC relative literal loads
(
-mpc-relative-literal-loads) has been deprecated and will be removed in a future release. This feature is no longer required with the improvements in constant anchors. - An option to specify which ISA will be used for auto-vectorization
(
-mautovec-preference) has been added. - GCC and Binutils no longer gate access to system registers by default.
A new flag (
-menable-sysreg-checking), enables the checks that were being applied in previous versions. - AArch64 now supports MTE stack tagging through
-fsanitize=memtag. You are still required to enable the MTE extensions via an appropriate-march=or-mcpu=. - ARM SPE has been added as a profiler to gcc-auto-profile and AutoFDO is now regularly tested on AArch64.
- A target specific pass that tranforms writes to 64-bit x-registers to use
32-bit w-registers equivalents when the upper 32 bits are provably zero
was added. It is currently only enabled for
-mcpu=olympus. - The following architecture level is now supported by
-marchand related source-level constructs (GCC identifiers in parentheses):- Armv9.6-A (
armv9.6-a)
- Armv9.6-A (
- The following CPUs are now supported by
-mcpu,-mtune, and related source-level constructs (GCC identifiers in parentheses):- Ampere1c (
ampere1c) - Apple M4 (
apple-m4) - Apple M5 (
apple-m5) - Arm AGI CPU (
armagicpu) - Arm C1 Nano (
c1-nano) - Arm C1 Pro (
c1-pro) - Arm C1 Premium (
c1-premium) - Arm C1 Ultra (
c1-ultra) - Arm Cortex-A320 (
cortex-a320) - Hisilicon's hip12 (
hip12) - NVIDIA GB10 (
gb10)
- Ampere1c (
- Support for the following CPUs has been improved (GCC identifiers in
parentheses):
- FUJITSU-MONAKA (
fujitsu-monaka) now supports FAMINMAX, FP8FMA, FP8DOT2, FP8DOT4, LUT features. - Olympus (
olympus) has an improved tuning model. - Apple M3 (
apple-m3) has an improved model.
- FUJITSU-MONAKA (
- Build attributes are now supported for marking GCS enabled code.
- C & C++ support for packed boolean vectors has been added enabling the use of normal operators with SVE booleans.
- The C++ spaceship operator (
<=>) has been optimized. - Function Multi Versioning (FMV) is no longer experimental and is now fully supported.
- Support for the
preserve_nonecalling convention has been added to support applications that require fewer caller saved registers. - The following features are now accepted by
-march,-mcpu, and related source-level constructs (GCC modifiers in parentheses):- FEAT_CMPBR (
+cmpbr), enabled by default for Arm9.6-A and above - FEAT_F16F32DOT (
+f16f32dot) - FEAT_F16F32MM (
+f16f32mm) - FEAT_F16MM (
+f16mm) - FEAT_F8F16MM (
+f8f16mm) - FEAT_F8F32MM (
+f8f32mm) - FEAT_FPRCVT (
+fprcvt) - FEAT_GCIE (
+gcie) - FEAT_LSCP (
+lscp) - FEAT_LSCP (
+lscp) - FEAT_LSFE (
+lsfe) - FEAT_LSUI (
+lsui), enabled by default for Arm9.6-A and above - FEAT_MOPS_GO (
+mops-go) - FEAT_MPAMv2 (
+mpamv2) - FEAT_MTETC (
+mtetc) - FEAT_OCCMO (
+occmo), enabled by default for Arm9.6-A and above - FEAT_PCDPHINT (
+pcdphint) - FEAT_POE2 (
+poe2) - FEAT_PoPS (
+pops) - FEAT_SME_F8F16 (
+sme-f8f16) - FEAT_SME_F8F32 (
+sme-f8f32) - FEAT_SME_LUTv2 (
+sme-lutv2) - FEAT_SME_MOP4 (
+sme-mop4) - FEAT_SME2p2 (
+sme2p2) - FEAT_SME2p3 (
+sme2p3) - FEAT_SSVE_AES (
+ssve-aes) - FEAT_SSVE_BitPerm (
+ssve-bitperm) - FEAT_SSVE_FEXPA (
+ssve-fexpa) - FEAT_SVE_AES2 (
+sve-aes2) - FEAT_SVE_B16MM (
+sve-b16mm) - FEAT_SVE_BFSCALE (
+sve-bfscale) - FEAT_SVE_F16F32MM (
+sve-f16f32mm) - FEAT_SVE2p2 (
+sve2p2) - FEAT_SVE2p3 (
+sve2p3) - FEAT_TEV (
+tev) - FEAT_TLBID (
+tlbid) - FEAT_TMOP (
+sme-tmop)
- FEAT_CMPBR (
- The following additional changes have been made to the
command-line options:
- SME without SVE is now supported.
- Support has been added for the following features of the Arm C
Language Extensions
(ACLE):
- __sqrt (in arm_acle.h)
- __sqrtf (in arm_acle.h)
- __atomic_store_with_stshh (in arm_acle.h)
- __pldir (in arm_acle.h)
- svamin and svamax instrinsics (enabled by
+sme2+faminmax) - svluti4_zt, svwrite_lane_zt and svwrite_zt intrinsics (enabled by
+sme-lutv2) - SME/SME2/SVE2.1/SME2.1 intrinsics like svread*, svwrite*, svsel*, svzip*, svzipq*, svuzp*, svuzpq*, svld1*, svld1_vnum*, svldnt1*, svldnt1_vnum*, svrevd*, svst1*, svst1_vnum*, svstnt1*, svstnt1_vnum*, svreadz_hor*, svreadz_ver*, svreadz_za* now support svmfloat8_t types.
- Widening and narrowing SME2 FP8 conversions (enabled by
+sme2+fp8) - Multi-vector floating-point adjust exponent fscale instrinsics
(enabled by
+sme2+fp8) - Multi-vector 8-bit floating-point multiply-add long instrinsics
(enabled by
+sme-f8f16or+sme-f8f32) - 8-bit floating-point sum of outer products and accumulate instrinsics
(enabled by
+sme-f8f16or+sme-f8f32) - 8-bit floating-point floating point dot product instrinsics (enabled
by
+sme-f8f16or+sme-f8f32) - SVE and Streaming SVE floating-point matrix multiply-accumulate
instrinsics (enabled by
+ssve-f16f32mm,+sve2+f8f16mmor+sve2+f8f32mm) - AdvSIMD floating-point matrix multiply-accumulate instrinsics (enabled
by
+f8f16mmor+f8f32mm) - SVE floating-point adjust exponent instrinsics (enabled by
+sve-bfscale) - The predefined macro
__ARM_BUILDATTR64_FV(enabled when build attributes support is available in gas) - The predefined macro
__ARM_FEATURE_F8F16MM(enabled by+f8f16mm) - The predefined macro
__ARM_FEATURE_F8F32MM(enabled by+f8f32mm) - The predefined macro
__ARM_FEATURE_SME_F8F16(enabled by+sme-f8f16) - The predefined macro
__ARM_FEATURE_SME_F8F32(enabled by+sme-f8f32) - The predefined macro
__ARM_FEATURE_SVE_BFSCALE(enabled by+sve-bfscale) - The predefined macro
__ARM_FEATURE_SVE_PREDICATE_OPERATORS(enabled by+sve) - The predefined macro
__HAVE_FUNCTION_MULTI_VERSIONING - The predefined macro
__ARM_FEATURE_SME_LUTv2(enabled by+sme-lutv2)
- In addition, the following changes have been made to preexisting
ACLE features:
- FP8 intrinsics can use constants for the fpm_t argument
+sve2-sm4,+sve2-sha3,+sve2-bitperm, and+sve2-aesnow imply both+sve2and the new options+sve-sm4,+sve-sha3,+sve-bitperm, or+sve-aesrespectively.
arm
- C23's
_BitIntfeature is now supported. - libatomic is now automatically linked as needed.
- Support for the deprecated iWMMXT extension has been removed.
IA-32/x86-64
- GCC now supports AMD CPUs based on the Zen6 core via
-march=znver6. This switch enables the AVX512_BMM, AVX_NE_CONVERT, AVX_IFMA, AVX_VNNI_INT8 and AVX512_FP16 ISA extensions on top of ISA extensions enabled for Zen5. - Auto-vectorization will now try to use a masked vector epilog when
AVX512 support is enabled and tuning for
znver4,znver5orznver6, saving code size and improving performance. - GCC now supports the Intel CPU named Wildcat Lake through
-march=wildcatlake. Wildcat Lake is based on Panther Lake. - GCC now supports the Intel CPU named Nova Lake through
-march=novalake. Based on ISA extensions enabled on Panther Lake, the switch in addition enables the APX_F, AVX10.1, AVX10.2 and PREFETCHI ISA extensions. - Since GCC 16, AMX-TRANSPOSE and USER_MSR are not enabled through
the compiler switch
-march=diamondrapidsany longer. CLDEMOTE is not enabled through the compiler switches-march=alderlake,-march=arrowlake,-march=arrowlake-s,-march=gracemont,-march=lunarlake,-march=meteorlake,-march=pantherlakeand-march=raptorlakeany longer. KL and WIDEKL are not enabled through the compiler switches-march=clearwaterforestand-march=pantherlakeany longer. PREFETCHI is not enabled through the compiler switch-march=pantherlakeany longer. -mavx10.1-256,-mavx10.1-512, and-mevex512were removed together with the warning for the behavior change on-mavx10.1.-mavx10.1has enabled AVX10.1 intrinsics with 512-bit vector support since GCC 15.- Support for AMX-TRANSPOSE was removed in GCC 16. GCC will no longer accept
-mamx-transpose, - The new
--enable-x86-64-mfentryconfigure option enables-mfentrywhich uses__fentry__, instead ofmcountfor profiling on x86-64. This option is enabled by default for glibc targets. --enable-tls=DIALECTis now supported to control the default TLS dialect. The default remainsgnu. The accepted values aregnuandgnu2(for TLS descriptors).
AMD GPU (GCN)
- For offloading to AMD GPUs: The launch overhead of OpenMP target regions and OpenACC compute regions has been drastically reduced.
- Experimental support for AMD Instinct MI300 (
gfx942) devices has been added, including the genericgfx9-4-genericand mostly compatiblegfx950. - By default, the following multilibs are now built:
gfx908,gfx90a,gfx9-generic,gfx9-4-generic,gfx10-3-generic, andgfx11-generic. Multilibs for specific devices are no longer built by default if a generic arch exists. Note:- When compiling for a specific arch and the multilib only exists for the associated generic arch, GCC's error message suggests the command-line option to do so.
- Generic architectures require ROCm 6.4.0 or newer.
- The new default-built set of multilibs now requires the assembler and linker of LLVM 20 or newer.
- Consult GCC's AMD installation notes and configuration notes for setting the multilibs to be build.
LoongArch
- Bit-precise integer types (
_BitInt (N)andunsigned _BitInt (N)) are supported. - Added FunctionMulti-Versioning (FMV) support. The
target_clonesattribute can be used to generate multiple function versions for different LoongArch CPU features (e.g.,lsx,lasx), with automatic runtime selection of the optimal version based on CPU capabilities. - Added support for the LoongArch32 architecture, including the
ilp32d(default),ilp32f, andilp32sABIs.
This covers both the standard 32-bit version (LA32) and the reduced 32-bit version (LA32R), enabling GCC to generate 32-bit target code for a wider range of embedded applications.
(Note: This feature depends on corresponding Binutils and glibc support.) - Switch the default code model to
medium. - Implement intrinsics for 128-bit and 256-bit vector conversions.
S/390, System z, IBM z Systems
- Bit-precise integer types (
_BitInt (N)andunsigned _BitInt (N)) are supported, now. - Floating-point type
_Float16is supported. All operations are carried out in software or byfloatinstructions. - Global stack protector support has been added and exported via
-mstack-protector-guard=global. Option-mstack-protector-guard-recordwas added, too. The primary use is for the Linux kernel in order to support run-time patching of the address loading of the canary. - Support for
-m31is deprecated and will be removed in a future release.
Operating Systems
Solaris
- GCC now supports the easy generation of Solaris CTF (Compact C Type
Format) with the
-gsctfoption. More information can be found in thectf(5)manual page.
Windows
- GCC now supports native TLS (Thread-Local Storage) on Windows. In order
to enable it,
--enable-tlsmust be specified at configure time and recent GNU binutils must be used (version 2.44 or later).
Improvements to GCC Diagnostics
- GCC can now output diagnostics in HTML form via
-fdiagnostics-add-output=experimental-html - GCC's SARIF output now respects the
dump directory.
For example, given
GCC 15 would write the SARIF togcc \ -o build-dir/foo.o \ -fdiagnostics-add-output=sarif foo.cfoo.c.sarif, whereas GCC 16 now writes it tobuild-dir/foo.c.sarif. - GCC's SARIF output now captures the nesting of logical locations.
- In GCC's SARIF output,
fixobjects now containdescriptionproperties in many cases. - GCC's SARIF output has gained 5 new values for the
§3.38.8
kindsproperty ofthreadFlowLocation, for expressing non-standard control flow:throwfor throwing an exceptioncatchfor catching an exceptionunwindfor unwinding stack frame(s) during exception-handlingsetjmpfor calls to setjmplongjmpfor calls to longjmp that rewind the program counter/stack to the location of a previous setjmp call
- GCC diagnostics can now have directed graphs associated with them, and
can also report "global" directed graphs. Graphs are ignored by text sinks,
but are captured by SARIF sinks, and the "experimental-html" renders any
such graphs in SVG-based form using dot. For example, setting
cfgs=yeson a SARIF or HTML diagnostic sink will enable capturing GCC's intermediate representation of every function at every optimization pass. - GCC diagnostics can now refer to logical locations inside XML and JSON
files (such as via libgdiagnostics). The
sarif-replaytool now uses this to provide JSON pointers when it reports on issues in its SARIF input. - If
GCC_DIAGNOSTICS_LOGis set in the environment, GCC's diagnostic subsystem will emit a text log to stderr (or a named file) to track what it's doing and the decisions it's making (e.g. exactly when and why a diagnostic is being rejected). - If
EXPERIMENTAL_SARIF_SOCKETis set in the environment, GCC will attempt to connect to that socket on startup and send JSON-RPC notifications to it for every diagnostic emitted.
Improvements for plugin authors
- GCC has gained a "publish/subscribe" framework, allowing for
loosely-coupled senders and receivers, with strongly-typed messages
passing between them. In this release the only topics for plugins
to subscribe to are:
- events relating to optimization passes starting/stopping on particular functions
- events relating to the static analyzer
- GCC diagnostic sinks can now have
extensionobjects associated with them, with afinalizerhook. Plugins can use this to capture additional information in SARIF output files. - GCC's diagnostic machinery has been substantially cleaned up in GCC 16.
This should not affect plugins that use just the
diagnostic-core.hheader, but maintainers of plugins making more sophisticated uses of diagnostics may need to refer to the porting guide.
Improvements to Static Analyzer
- The analyzer is now usable on simple C++ examples, as it now handles C++'s Named Return Value Optimization and has some initial support for exceptions. However due to scaling issues it is not likely to be usable on production C++ code in this release.
- With the added support for exception-handling,
-fanalyzerassumes that a call to an external function not marked with attributenothrowcould throw an exception if-fexceptionsis enabled. GCC 16 adds a new option-fanalyzer-assume-nothrow, for disabling this assumption. This is intended as a workaround for projects where the exception-handling generates large numbers of new warnings, such as C code where-fexceptionsis used for interoperability with C++ but where the C APIs in use are unlikely to throw exceptions. - The data structure used by
-fanalyzerfor representing the user's code has been rewritten in a way that makes it easier to understand and debug, and slightly improves locations used when reporting diagnostics. This comes at the cost of increasing the memory usage of the analyzer. - The data structure used by
-fanalyzerfor simulating the contents of memory in the user's program has been reimplemented. The new implementation is faster and easier to maintain. - The analyzer has started to make use of GCC's
value_rangemachinery, eliminating some false positives.
Improvements to libgdiagnostics
libgdiagnostics has gained 37 entrypoints:- 5 new entrypoints for working with logical locations
- 2 new entrypoints for supporting command-line options and SARIF playback
- 12 new entrypoints for working with directed graphs:
diagnostic_manager_new_graph()diagnostic_manager_take_global_graph()diagnostic_take_graph()diagnostic_graph_release()diagnostic_graph_set_description()diagnostic_graph_add_node()diagnostic_graph_add_edge()diagnostic_graph_get_node_by_id()diagnostic_graph_get_edge_by_id()diagnostic_node_set_label()diagnostic_node_set_location()diagnostic_node_set_logical_location()
- 17 new entrypoints for building up text for a diagnostic via a buffer:
diagnostic_message_buffer_new()diagnostic_message_buffer_release()diagnostic_message_buffer_append_str()diagnostic_message_buffer_append_text()diagnostic_message_buffer_append_byte()diagnostic_message_buffer_append_printf()diagnostic_message_buffer_append_event_id()diagnostic_message_buffer_begin_url()diagnostic_message_buffer_end_url()diagnostic_message_buffer_begin_quote()diagnostic_message_buffer_end_quote()diagnostic_message_buffer_begin_color()diagnostic_message_buffer_end_color()diagnostic_message_buffer_dump()diagnostic_finish_via_msg_buf()diagnostic_add_location_with_label_via_msg_buf()diagnostic_execution_path_add_event_via_msg_buf()
diagnostic_manager_set_debug_physical_locations()
Other significant improvements
This is the list of problem reports (PRs) from GCC's bug tracking system that are known to be fixed in the 16.1 release. This list might not be complete (that is, it is possible that some PRs that have been fixed are not listed here).