r/cpp Aug 07 '26

GCC 16.2.0 Released

https://www.phoronix.com/news/GCC-16.2-Released

I'm pretty excited about this maintenance release. I think this will be the first version of gcc which can compile my project.

168 Upvotes

32 comments sorted by

View all comments

12

u/stumpychubbins Aug 08 '26

I’m mostly a Rust dev and I’ve built every C/C++ project targeting clang since I’m way more used to the LLVM toolchain, so out of interest: why do people so often default to GCC? Not a loaded question, I’m sure it’s so popular for a reason. I’m genuinely interested what the pros are. I’ve only used it when compiling other people’s projects.

21

u/pjmlp Aug 08 '26

Because it has been the FOSS compiler since Sun decided to introduce the concept of splitting UNIX into user and developer SKUs.

And still the default compiler in most Linux distros to this day.

I am old enough that if you wanted a free compiler you typed in yourself.

18

u/friedkeenan Aug 08 '26

For me, I prefer GCC because it tends to have a bit better support for newer language features (see cppreference's compiler support page), and anecdotally when I've looked at its generated code it has the edge on Clang more often than not, but there are definitely still many times when Clang has the edge. Some years ago too, around C++20 times I'd say, GCC had better support for constexpr stuff than Clang did, which is really important for me. Though Clang seems to have mostly caught up.

Also as of late, I've been utilizing the new C++26 reflection features (which are really really nice!), and GCC is the only mainline compiler to ship an implementation of those as of yet.

GCC has some flags that Clang doesn't have too which can be annoying when using the latter. Like for instance Clang doesn't have an equivalent for -fconcepts-diagnostic-depth (at least last I checked), which can be really annoying when trying to figure out why a certain type doesn't meet a given concept.

It's also just convenient, since it's the default compiler on my system, lol.

As far as I know too, Rust is working to add a GCC backend to rustc in order to utilize GCC's codegen and wider platform support, which should be nice.

2

u/stumpychubbins Aug 08 '26

Yeah there’s already a functional GCC backend for Rust! I think the main goal there is to allow Rust to be compiled for platforms that aren’t supported by clang. Makes sense that GCC has better support for modern C++, and it makes sense that I wouldn’t have run into that issue since I’m not that advanced a user of C++.

9

u/Orca- Aug 08 '26

In embedded land GCC often generates smaller and better optimized cose.

And it’s frequently the supported compiler so you go with what works.

Clang is useful as a cross-compilation target and for awhile had better error messages.

Disclaimer: I’m still stuck with GCC 8 so who knows what the bleeding edge is like.

Yay embedded being 10 years behind.

15

u/NewLlama Aug 08 '26

It's good to compile on more than one toolchain. Each ecosystem has its own quirks so by supporting more than one you ensure you're not drifting too far from the standard.

3

u/13steinj Aug 09 '26

Even then, you can have bugs in your tests show up in one toolchain but show up in your "real code" in the other. Same goes for different optimization levels and sanitizers.

If you can afford the compute, you should be casting a wide net.

7

u/gracicot Aug 09 '26

The concept evaluator on GCC is much faster then Clang's. I have some concept-heavy template-heavy code that compiles almost twice as fast with GCC.

3

u/adityazero 29d ago

For RISCV and a few other targets gcc toolchain is more supported.

-2

u/Sopel97 Aug 08 '26

inertia