After a year of development, the release of the free GCC 15.1 compiler suite is now available, marking the first significant release in the new GCC 15.x branch. According to the release numbering scheme, version 15.0 was used during development, and shortly before the release of GCC 15.1, the GCC 16.0 branch had already diverged, which will form the basis for the next significant release GCC 16.1.
Key Changes:
- When compiling programs in C, the default standard is now C23 (changes overview) with GNU extensions ("-std=gnu23"). Previously, the default was the C17 standard — "-std=gnu17". This change may potentially cause issues when building existing projects due to the inclusion of the nullptr constant, the _BitInt(n) type, and the keywords bool, true, and false, which may conflict with identically named identifiers defined in applications.
- The features of the C23 standard have been implemented:
- The directive "#embed", intended for embedding binary resources into the code.
- The attribute "unsequenced", indicating that the result does not depend on the order of execution.
- The attribute "reproducible", indicating that the function always returns the same result for the same inputs, i.e., it does not depend on other factors.
- Elements of the future C2Y standard (-std=c2y and -std=gnu2y) have been implemented:
- The ability to declare variables in the "if" statement, for example, "if (int x = get ()) {…}".
- Support for naming loops so that they can reference in the code. outer: for (int i = 0; i < IK; ++ i) { switch (i) { case 1: break; // jumps to CONT1 case 2: break outer; // jumps to CONT2 } // CONT1 } // CONT2
- Support for specifying ranges of integer values in "case" statements, for example, "case 1 … 10:".
- The suffixes "i" and "j" to denote the imaginary part in complex numbers.
- The ability to use the "++" and "—" operators with complex numbers.
- The construction "_Generic(type, expr1, expr2, …)" for selecting expressions based on the operand type.
- Support for treating byte arrays as other types of objects such as structures and unions.
- Support for applying the "alignof" operator to incomplete arrays (declared without a specified size, e.g., "int a[]").
- A new syntax has been added for octal, hexadecimal, and universal character escape sequences. Instead of "\u", "\x", and "\nnn", the sequences "\u{}", "\o{}", and "\x{}" are proposed, where any number of digits can be specified.
- Built-in functions "__builtin_stdc_rotate_left" and "__builtin_stdc_rotate_right".
- Operations with zero-length on NULL pointers are allowed (for example, "sizeof(*p)").
- Frontend capabilities for C++ have been implemented, evolving towards the future C++26 standard:
- Variadic operator "friend" ("friend Ts...").
- The ability to use the keyword "constexpr" with the placement new operator to construct an object in pre-allocated memory at compile time.
- Error output when deleting a pointer to an incomplete type.
- The syntax for defining variadic parameters with ellipsis without a preceding comma has been deprecated (for example, specifying "void e(int…)" instead of "void e(int, …)").
- Indexing of parameter packs in templates.
- Attributes for structured bindings;
- Syntax ‘= delete(“reason”)’;
- Inclusion of "@", "$", and "`" in the basic character set.
- The use of macros to declare modules has been prohibited.
- The ability to apply structured binding as a condition in if and switch statements.
- Direct comparison of arrays has been discontinued (for example, "int arr1[5]; int arr2[5]; bool same = arr1 == arr2").
- The mechanism "#embed" for embedding binary resources.
- The template class is_trivial has been deprecated.
- New features of C++23 added:
- Prohibition of certain usages of the export directive and permission to use "export {}".
- Support for extending the lifetime of temporary objects in for loops that iterate over ranges.
- Experimental support for std and std.compat modules has been implemented in the libstdc++ library.
- Using the initializer "{0}" for unions in C and C++ code no longer guarantees that all content will be cleared, but results in zeroing the first element of the union. To clear the entire union, one should use the expression "{}" defined in the C23 specification or specify the option "-fzero-init-padding-bits=unions" to restore the old behavior.
- Support for the 'musttail' attribute ([[gnu::musttail]] and [[clang::musttail]]) has been implemented for guaranteed tail calls. The attribute is applied to return statements that involve a recursive call to the current function, ensuring that such calls will utilize tail recursion, which does not allocate additional memory on the stack (eliminating the risk of memory exhaustion with a very large number of calls).
- Support for the flag_enum attribute ([[gnu::flag_enum]] and [[clang::flag_enum]]) has been implemented, which is applied to enumerations to indicate that their contents are used in bit operations (preventing warning output in '-Wswitch' mode).
- Support for the 'counted_by' attribute has been added, allowing you to specify a field in a structure with a flexible array that defines the number of elements. This attribute can be used to enhance the efficiency of boundary checks.
- A 'nonnull_if_nonzero' attribute has been added for functions, specifying that certain function parameters with pointers may accept a NULL value only if another parameter is zero.
- Extended assembly inserts 'asm (…)' are allowed outside of functions. In assembly inserts, overwriting memory in the red zone of the stack (the area at the top of the stack) is permitted.
- Compilation of C++ code has been accelerated due to improved template hashing.
- New optimizations have been added. Support for vectorizing loops containing code for premature exit (e.g., through a break or return call) has been implemented, even if such loops manipulate dynamically allocated arrays or buffers whose size is unknown at compile time. When the '-O2' option is specified, vectorization of certain easily vectorizable loops for which tripcount information is unavailable is enabled.
- An incremental optimization mode at the linking stage (LTO, Link-Time Optimization) has been added, significantly reducing recompilation time when using LTO in situations where only minor changes are made to the code (one function edited). The option '-flto-incremental' is suggested to enable the incremental mode.
- The compilation of very large input files has been improved. Column number tracking for numbers exceeding 4096 has been implemented. The accuracy of indicating the locations of errors and warnings in very large files has been enhanced.
- The clarity of reports during diagnostics has been improved. For example, issues are now highlighted with a symbol '⚠️', the output layout for errors in C++ templates has been changed, hints have been added to facilitate the transition to standard C23, and the color scheme has been revamped. The option to output diagnostics in Sarif format (-fdiagnostics-format=sarif-file) has been added.
- The libgdiagnostics library has been implemented, allowing integration of GCC's diagnostic message formatting capabilities into your projects (for example, features like quoting, highlighting, and hints for corrections can be utilized).
- Warnings '-Wtrailing-whitespace' and '-Wleading-whitespace' have been added to identify residual spaces at the end of lines and unnecessary spaces at the beginning of lines.
- The warning '-Wheader-guard' has been added to inform about issues in header guard macros that prevent the re-inclusion of header files.
- The front end for the D language has been updated to version 2.111.0.
- Support for unsigned integers has been added in the front end for the Fortran language.
- The compiler for the COBOL language — gcobol, which supports x86-64 and AArch64 platforms, has been included and is not intended for use on 32-bit systems. The compiler implements the ISO/IEC 1989:2023 specification and passes most NIST CCVS/85 tests.
- The implementation of OpenMP 5.0, 5.1, 5.2, and 6.0 standards (Open Multi-Processing), which define the API and methods for applying parallel programming techniques on multi-core and hybrid (CPU+GPU/DSP) systems with shared memory and SIMD vectorization blocks, has continued. Support for meta-directives and constructs such as tile, unroll, interop, and dispatch has been added. Unified shared memory support for some AMD and NVIDIA GPUs has been added (enabled by specifying unified_shared_memory in the 'requires' directive). Support for the expression 'self_maps' has been added.
- Support for the MinGW platform (aarch64-w64-mingw32) has been added to the back end for the AArch64 architecture. Over 20 ARM8 extensions have been implemented, and support for the ACLE (Arm C Language Extensions) has been improved. Numerous enhancements have been made to the code generator. Support for CPU has been added:
- Apple A12 (apple-a12)
- Apple M1 (apple-m1)
- Apple M2 (apple-m2)
- Apple M3 (apple-m3)
- Arm Cortex-A520AE (cortex-a520ae)
- Arm Cortex-A720AE (cortex-a720ae)
- Arm Cortex-A725 (cortex-a725)
- Arm Cortex-R82AE (cortex-r82ae)
- Arm Cortex-X925 (cortex-x925)
- Arm Neoverse N3 (neoverse-n3)
- Arm Neoverse V3 (neoverse-v3)
- Arm Neoverse V3AE (neoverse-v3ae)
- FUJITSU-MONAKA (fujitsu-monaka)
- NVIDIA Grace (grace)
- NVIDIA Olympus (olympus)
- Qualcomm Oryon-1 (oryon-1)
- Support for the libstdc++ library has been implemented in the backend for AMD Radeon (GCN) GPU code generation, along with experimental support for code generation for gfx9-generic, gfx10-3-generic, and gfx11-generic device series.
- Support for Intel AVX10.2, AMX-AVX512, AMX-FP8, AMX-MOVRS, AMX-TF32, AMX-TRANSPOSE, and MOVRS instruction set architecture extensions has been added to the x86 backend. Support for Intel Diamond Rapids and Xeon Phi CPUs has also been included.
- Backend capabilities for LoongArch and AVR platforms have been expanded.
- Support for the nios2 target architecture used in Nios II processors has been removed. The ABI ILP32 (-mabi=ilp32) support in the AArch64 port has been deprecated and will be removed in the next major release.
Source: opennet.ru
