Live data from Hacker News

GCC 16 considering changing default to C++20

inbox.sourceware.org

71–80 of 119 posts

Re: GCC 16 considering changing default to C++20

#71
post #47

Earlier quoted context omitted.

That's not a counterpoint—at least not to anything in the comment that you're (nominally) "responding" to. So why has it been posted it as a reply, and why label it a counterpoint?

Read them again a couple more times and it may become clear. The prior post seemed to be claiming that this required any form of a bootstrapping process, when it does not.

You have lost the plot, and you are wrong.

Re: GCC 16 considering changing default to C++20

#72

Earlier quoted context omitted.

This is not the case. They are discussing the default value of `g++ -std=...`. That does not complicate bootstrapping as long as the C++ sources of GCC are compatible with older and newer versions of the C++ standard.

> as long as the C++ sources of GCC are compatible with older and newer versions of the C++ standard. I've worked on a number of pretty large projects. If the target for the source code changes it can be really hard to keep C++20 features from creeping in. It means that you either need to explicitly build targeting 11, or whoever does code reviews needs to have encyclopedic knowledge of whether or not a change leaked…

Compilers often allow things in 11 that technically are not there until some later standard. Or sometimes things they have always allowed finally got standardized in a later version. Setting your standard to 11 if that is what you want to target it a good first step but don't depend on it - the real tests is all the compilers you care to support compile your code.

Even if you only target 11, there may be advantages to setting a newer version anyway. Sometimes the standard finally allows some optimization that would work, or disallows something that was always error prone anyway. I would recommend you set your standard to the latest the compiler supports and fix any bugs. Solve your we have to support older standards problem by having your CI system build with an older compiler (and also the newest one). C++ is very good at compatibility so this will rarely be a problem.

Re: GCC 16 considering changing default to C++20

#73
post #53

Shouldn't the compilers be on the bleeding edge of the standards? What is the downside of switching to the newest standard when it's properly supported? It's the type of dog fooding they should be doing! It's one reason why people care so much about self-hosted compilers, it's a demonstration of maturity of the language/compiler.

This is about changing the default. The issue with defaults is that people have projects that implicitly expect the default to be static. So when the default changes, many projects break. This is maybe fine if it’s your own project but when it’s a few dependencies deep, it becomes more of an issue to fix.

C++ is very good at compatibility. If your code breaks when the standard changes, odds are it was always broke and you just didn't know. C++ isn't perfect, but it is very good.

Re: GCC 16 considering changing default to C++20

#74
post #68
post #33

Earlier quoted context omitted.

> What is the downside of switching to the newest standard when it's properly supported? Backwards compatibility. Not all legal old syntax is necessarily legal new syntax[1], so there is the possibility that perfectly valid C++11 code exists in the wild that won't build with a new gcc. [1] The big one is obviously new keywords[2]. In older C++, it's legal to have a variable named "requires" or "consteval", and now it…

well, shouldn't not-up-to-date code use the corresponding compiler flag instead of someone starting a greenfield project, who might then write outdated code?

No? The "corresponding compiler flag" is a new feature. I mean, who told folks at Bell Labs in 1978 how the GCC --std= arguments would work in the coming decades? Legacy code is legacy, it doesn't know it needs to use the correct flags. When it was a greenfield project, it was the default!

Like, think about it: if you think the defaults should be good for greenfield projects, then greenfield projects won't be using the correct flags (because if they are, then the whole argument is specious anyway). And when C++34 shows up, they're going to be broken and we'll have this argument again.

Compatibility is hard. But IMHO C++ and gcc are doing this wrong and C is doing it much better.

Re: GCC 16 considering changing default to C++20

#75
post #69

Shouldn't the compilers be on the bleeding edge of the standards? What is the downside of switching to the newest standard when it's properly supported? It's the type of dog fooding they should be doing! It's one reason why people care so much about self-hosted compilers, it's a demonstration of maturity of the language/compiler.

> What is the downside of switching to the newest standard when it's properly supported? "Properly supported" is the key here. Does GCC currently properly support C++23, for example? When I checked a few months ago, it didn't.

Where do you draw the line for properly supported? I've been using g++ in c++23 mode for quite some time now - even if every feature is not entirely implemented, the ones that work, work well and are a huge improvement

Re: GCC 16 considering changing default to C++20

#77

Shouldn't the compilers be on the bleeding edge of the standards? What is the downside of switching to the newest standard when it's properly supported? It's the type of dog fooding they should be doing! It's one reason why people care so much about self-hosted compilers, it's a demonstration of maturity of the language/compiler.

A lot of software, and thus build automation, will break due to certain features that become warnings or outright errors in new versions of C++. It may or may not be a lot of work to change that, and it may or may not even be possible in some cases. We would all like there to be unlimited developer time, but in real life software needs a maintainer.

I'm not talking about software compiled by the compiler having a higher default.

Warnings becoming errors would be scoped to gcc itself only, and they can fix them as part of the upgrade.

Re: GCC 16 considering changing default to C++20

#78
post #47

Earlier quoted context omitted.

That's not a counterpoint—at least not to anything in the comment that you're (nominally) "responding" to. So why has it been posted it as a reply, and why label it a counterpoint?

Read them again a couple more times and it may become clear. The prior post seemed to be claiming that this required any form of a bootstrapping process, when it does not.

This particular compiler does require bootstrapping, and that's obviously what "the compiler" is referring to in that comment.

Building your compiler in another language doesn't help at all. In fact, it just makes it worse. Dogfooding C++20 in your compiler that isn't even built in C++ is obviously impossible.

Re: GCC 16 considering changing default to C++20

#79
post #69

Earlier quoted context omitted.

> What is the downside of switching to the newest standard when it's properly supported? "Properly supported" is the key here. Does GCC currently properly support C++23, for example? When I checked a few months ago, it didn't.

Where do you draw the line for properly supported? I've been using g++ in c++23 mode for quite some time now - even if every feature is not entirely implemented, the ones that work, work well and are a huge improvement

I draw the line where I can't expect the default gcc on most Linux and Mac systems to compile my code. And I don't want to force them to install a particular compiler. -std=c++20 seems to work pretty reliably these days.

We're starting to need caniuse.com for C++.

Re: GCC 16 considering changing default to C++20

#80
post #73
post #53

Earlier quoted context omitted.

This is about changing the default. The issue with defaults is that people have projects that implicitly expect the default to be static. So when the default changes, many projects break. This is maybe fine if it’s your own project but when it’s a few dependencies deep, it becomes more of an issue to fix.

C++ is very good at compatibility. If your code breaks when the standard changes, odds are it was always broke and you just didn't know. C++ isn't perfect, but it is very good.

On the other hand, if you didn't know your code was broken then it probably wasn't broken in a way that's catastrophic to whatever you use it for.
Post reply on HN