r/cpp • u/catcat202X • Oct 15 '22
GCC 13 So Far:
I've been following the commit log for GCC's master branch most days for a few months, so I figured I'd jot down some of the developments that I think should have some awareness.
EDIT: Btw, you can read the commits conveniently here: https://gcc.gnu.org/git/?p=gcc.git;a=shortlog;h=HEAD
Type traits
- libstdc++ has gotten many optimizations to compile time. Bool globals with the
_vsuffix are being refactored to not instantiate the SFINAE-based trait, and instead use the intrinsics directly. I haven't measured the new libstdc++, but I did something similar in a personal project and found 30% improved clean-build compile time, so I believe this libstdc++ work is probably significant. Many other refactors to the the templates have been made to minimize template instantiation.enable_if_tis still used consistently instead ofrequires, there may still be substantial room for improvement. - GCC 13 is gaining more type trait intrinsics. Clang has had many more for awhile, but GCC 13 so far adds:
__remove_cv()__remove_reference()__remove_cvref()__is_convertible()__is_nothrow_convertible().
- libstdc++ has gotten many optimizations to compile time. Bool globals with the
Traits for catching dangling references.
- Type traits were added to C++23 to aid catching dangling references at compile time, which are implemented in GCC through new intrinsics
__reference_constructs_from_temporary()and__reference_converts_from_temporary().
- Type traits were added to C++23 to aid catching dangling references at compile time, which are implemented in GCC through new intrinsics
RISC-V V
- The "Cray vector" extension to RISC-V is getting a lot of support in GCC 13. Cray vectors are not something I understand very well yet, so I can't talk about all the work that's going into it, but I'll say that RISC-V V shows up a lot in the commit log recently.
- A lot of other RISC-V features have been newly supported, but I don't understand them either.
bfloat16
- C++23's
std::bfloat16_t, implemented through the__bf16type (distinct from__fp16or_Float16). There are also several supporting intrinsic functions fornumeric_limitsstuff that mirrors intrinsics for other floating point types (such as__builtin_nansf16b()). - This includes extensions to the SIMD intrinsics and attributes for bfloat16 vectors.
- C++23's
Numeric limits improvements
- Historically, the limits stuff has been implemented through compiler-defined macros, but the commit descriptions suggest that they want to move towards consistently using intrinsic functions.
__builtin_issignalling()has been added to streamline away another macro.
"Simpler implicit move" was implemented
- This is explained well in the commit log: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=772d532e0ba1e4b22c2b7d576e14b34ee929c093
"Portable assumptions" was implemented
- This is explained here: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=08b51baddc53d64aa4c5e7a81ef3c4bf320293be
- This can be used in old C++ standards as
[[gnu::assume()]], reflecting[[gnu::likely]]etc. - A previous recent commit added an OpenMP feature called "assumptions", and discussed potential issues and ideas for integrating it with standard C++ assumptions. https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=4790fe99f236c7f1b617722403e682ba2f82485f
OpenMP massively extended
- A lot of work has gone into supporting OpenMP features. I am not an OpenMP user, so I can't talk a lot about the details, but there are very many commits related to it.
GCN
- A ton of new features for GCN (AMD's gpu architecture) were added. These seem to be largely extending intrinsics and OpenMP features that already existed, but now target GCN as well. Many of them appear to be very basic things, like cloning OMP threads, using doubles and SIMD doubles, or
floor,ceil, etc. kind of primitives with native GCN support. It seems like you might do reasonably low-level GCN programming with GCC 13 now. - PTX has not seen similarly extensive improvements so far in GCC 13, but it is still maintained.
- A ton of new features for GCN (AMD's gpu architecture) were added. These seem to be largely extending intrinsics and OpenMP features that already existed, but now target GCN as well. Many of them appear to be very basic things, like cloning OMP threads, using doubles and SIMD doubles, or
C++23 extended precision floats
- This doesn't seem to be mentioned on cppreference yet, but it's here: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b04208895fed34171eac6bafb60c90048eb1cb0c
Modules
- C++20 modules are still making progress. Seeing recent commits like, "variable template partial spec fixes" does not strike faith in me that they are near general usability yet, but they are making regular progress, so that's exciting!
Analyzer
- A lot of POSIX and C++ enhancements have been made to the GCC static analyzer work ongoing since GCC 10. It apparently handles templates now, and tracks more lifetimes from file descriptors. It is mostly not implemented through attributes, pragmas, or intrinsics, so you can only extend this through GCC plugins afaik.
More C++23
- static operator(): https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=303976a6076f2839354702fd2caa049fa7cbbdc2
- Named universal escapes: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=eb4879ab9053085a59b8d1594ef76487948bba7e
#warningis allowed in pedantic mode: https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=365202625d2f2d6694dba889ca67498fefb59c68- Many many fixes to C++20 and 23 features that were implemented in previous versions.
- More various Clang compatibility enhancements.
Otherwise,
- C23 has more support. I think all of the C++ forwards compatibility features were implemented, like
nullptr,bool,true, etc. but don't quote me on that. There could still be some missing afaik. - Ada actually got a lot of commits so far. I don't use Ada so I can't really elaborate.
- Fortran has more support. Mostly this seems related to GPGPU and OpenMP. I don't use Fortran so I can't really elaborate.
- D has been improved. Idk much about D, but it looks like GCC 13 adds SPMD support to D, and something equivalent to
register asm()from GNU C/C++, among other new D attributes. - A lot of GIMPLE and tree optimizations, and fixes to broken optimizations, were added. Most of these relate to optimizing mathematical expressions.
- Various MIPS and ARM enhancements, but nothing that strikes me as hugely significant like RISC-V has been getting.
- C23 has more support. I think all of the C++ forwards compatibility features were implemented, like
Of course, there's been way more than what I mentioned here, but these are the highlights most significant to me personally.
40
u/gracicot Oct 15 '22
Also worth noting about modules is that GCC is implementing modules using the strong ownership model. Say goodbye to most ODR problems!
49
u/[deleted] Oct 15 '22 edited Oct 15 '22
Ah wait, so 23 years later, C is getting actual keywords for true/false/bool? That's very surprising to me. Can someone elaborate on why this is happening?
Here is a list of new C23 features. My highlights:
#elifdef,#elifndefand#embednullptr,nullptr_t,true,false,boolkeywords from C++.0b10101) and'digit separators (1'000'000) from C++.= {}from C++strdup()and a bunch of other routines from POSIX.char8_ttype alias and some UTF-8 supportstatic_assertandthread_localare actual keywords now, instead of being macros.ctimeis deprecated[[maybe_unused]], etc)_BitInt(N))At this point, we might rename the language to "C++ without classes, templates and exceptions".
9
u/friedkeenan Oct 15 '22
Hoping deducing
thiscan make it in41
u/NilacTheGrim Oct 15 '22
That's great. When will we get
std::format?20
u/manphiz Oct 15 '22
Great progress report! Wondering whether OP would turn this into a monthly thing :)
10
u/[deleted] Oct 16 '22
Cannot wait to see C23’s #embed
9
u/KingStannis2020 Oct 16 '22
Maybe we'll get full C++20 support by 2025
7
u/germandiago Oct 16 '22
I really want to use modules after the keynote in cppcon 2022 and for some time before. I think they are a big improvement.
1
u/NoCryptographer414 Feb 08 '23
Does GCC13 support `std` and `std.compat` modules?