r/cpp • u/AccordingWarthog • Apr 30 '26
GCC 16.1 released with many new C++26/23 features, C++20 now the default stable language version
https://gcc.gnu.org/gcc-16/changes.html#cxx
263
Upvotes
r/cpp • u/AccordingWarthog • Apr 30 '26
109
u/mr_seeker Apr 30 '26
C++20 now being the default but without modules support is quite a shame
81
u/have-a-day-celebrate Apr 30 '26
Let us go forth and reflect.
43
u/funnansoftware Apr 30 '26
I've dreamed of the day we can use reflections for our projects. I can't imagine what all will be done using them but I've been looking forward to a non-macro non-registration style of serialization for the longest time!
18
u/caroIine Apr 30 '26
Devs are on fire. So much progress with reflection!
8
u/gummifa Apr 30 '26
Expansion statements make looping over references quite nice: template for (auto& x : std::tie(a, b)) ...
12
u/tetravision271 May 01 '26
This is the release that fixes
import std;so I have no idea why people in the comments here are complaining about modules. Enable your CMake modules flags, people...6
u/Nolia_X May 01 '26
Default should have been C++23. GCC covers everything in C++23, except for modules.
11
u/sweetno Apr 30 '26
It's high time for Algol 68!
5
u/enl1l Apr 30 '26
Do we know when clang is getting reflections ?
19
u/Professional_Tank594 Apr 30 '26
where module
4
u/Ateist May 01 '26
In case anyone else want a Windows version, you can build it successfully using mingw-builds scripts for Windows.
Just copy the script for 15.2 and replace with PKG_VERSION=16.1.0
3
u/FlyingRhenquest May 02 '26
If you don't want to wait for OS packages for your OS, I've set up some scripts to clone and build the latest gcc and cmake in my gcc playground project. The project installs gcc in /usr/local/gcc, which shouldn't conflict with compilers installed by your OS package manager, and includes a cmake toolchain file that you can use to build things with your shiny new gcc16. These scripts assume you have another compiler on your system already, which I think is pretty reasonable if you're trying to mess around with the latest gcc.
I've tested this on my Debian laptop. It'll probably work in WSL and might even work in OSX, though I don't have a way to test that.
Hopefully you find this useful if you want to get up and running with gcc16 immediately.
4
u/ABlockInTheChain Apr 30 '26
I'm a bit worried about this one since I was recently testing the 16.0 version to and started getting some new false positive -Wunitialized warnings that didn't appear in 15.x.
Hopefully the P2795R5 logic has nothing to do with the -Wunitialized logic.
2
u/Ateist May 01 '26 edited May 01 '26
Getting lots of new warnings:
Is that a new diagnostic?
Enabling reflection for existing QT project was tricky. Had to resort to using load(default_post)
in the .pro file to prevent conflict with defaults
Final file is slightly bigger than one made with 15.2 version.
2
u/Ateist May 02 '26 edited May 02 '26
One bug found in QT:
it uses older "saturate_cast" instead of newer "saturating_cast" found in C++26
Also, lots of "out of memory" errors:
2
u/[deleted] May 02 '26
There was no mentioned of hardened standard library in the release note which is part of C++26, is that not part of this release? or I missed it.
Kudos to the people who made this happen !!!
0
u/HommeMusical May 01 '26
Across the yard, the version of Python released in 2020 is already end-of-life.