120 pointsby siteshwarMay 19, 2026

4 Comments

ChristianJacobsMay 21, 2026
Great news! As someone who's moving back to a C++ job after having worked with Rust for several years now, the error message parsing is one of the things I've been dreading the most... I'm still dreading it, but now sliiightly less.

Also, that interactive `-fanalyze`-output with the pointer visualisation looks super handy!

Happy to see there's still focus on the DX in GCC. C and C++ sorely needs it.

vlovich123May 21, 2026
This has appeared multiple times over the years as “compiler improves c++ errors” and is even the reason given as motivating things like concepts. Sure it keeps improving but the errors don’t seem to actually get smaller. The problem is inherent to templates - c++ got it wrong by having templates start weakly typed and it has no mechanisms to correct it in the language - concepts helped but didn’t definitively fix it and also are a serious level of complexity (ie for writing and defining concepts) - it just shifted the burden one level but ultimately the mess is still there.

After more than 20 years in c++, I gave up that the situation will ever really be fixed vs constantly being made better at the margins, but not as fast as new ideas get added to the language.

ChristianJacobsMay 21, 2026
You're not wrong there. The late stage (compilation wise) of template instantiation doesn't help either, as so much context has been built up. The art of debugging C++ compiler output is knowing which 90% to ignore. If you read it all you'll simply go mad.

Concepts at least tells you which criteria you didn't satisfy (as long as the concept is correct...), which - admittedly - feels like putting a bandaid on bullet wound.

pjmlpMay 21, 2026
Concepts could be much better, but first we only got the light version, and secondly the effort hasn't been there regarding improving the error messages.

Also, so far I would say they haven't been getting people rushing out to use them anyway, as C++20 is still too new for many projects.

Even GCC only now changed to C++20 as default mode.

DavidbrczMay 21, 2026
Concepts have been disappointing for me: what they tell you is still buried in 1000 lines of errors.
estebankMay 21, 2026
Concepts support (like traits I'm Rust) is necessary for good diagnostics, but not sufficient. It gives you the architecture and metadata that you require to infer what the user wants, but a lot of additional analysis on the decision chain that was followed in order to figure out what is relevant and what isn't.
tialaramexMay 21, 2026
Also the C++ 20 "Concepts Lite" isn't a nominal system like Rust's traits (or like the C++ 0x Concepts proposal which Bjarne had ripped out), it's Duck typing again and so it's harder even if the work was done.

Rust can say hey, this code treats Mallard as if it's a Duck, did you mean for this Mallard to implement Duck? If so, try writing #[derive(Duck)]

But for Concepts Lite the compiler needs to guess that you wanted Mallard to match this requirement that Ducks can quack, and observe that Mallard's quack has a slightly wrong signature so it doesn't match and so that's probably the mistake.

gpderettaMay 21, 2026
concepts have been excellent for me for overload resolution in complex template code (good riddance SFINAE) and for documentation.

To improve error messages, not so much.

estebankMay 21, 2026
Even without having concepts, a cpp compiler could conceivably detect at definition time that the template is acting as a generics declaration only, and treat it specially as if it was a "late-bound concept". That would potentially help with codegen, but it would certainly help with making compile errors better. I find it is hard to convince compiler engineers to divorce themselves from what the language semantics are and what the compiler does. As long as the user visible behavior is the same, you can internally handle things differently for conceptually this same feature.

Rust has the same problem as templates with macros. We haven't had a strong need to customize the macrosl evaluation much, but I could very much see us special casing macros that are function like, or have macro arms that can only be a handful of things in order treat them different so diagnostics get better. The only thing that comes to mind thar we do today, is that when a macro call falls through (no macro arm matches), we retry it adding commas in between expressions to see if it was just a typo.

pjmlpMay 21, 2026
The problem isn't C++, the problem is that the meagre resources those teams have available, rather spend their time catching up to ISO C and ISO C++, than improving error messages.

Hence why SARIF has seen big adoption, as they hope that by exposing that , there are others ways to have others have tools that process SARIF.

ramon156May 21, 2026
While the new error message pinpoints the location of the error better, you have to dig through so much text to find it. Why not have a verbose mode that you can turn off so you only get the last trace of the error message? clippy does this so well, plus you get a suggested fix
gpderettaMay 21, 2026
SARIF is machine readable. An editor (or a shell filter if you prefer it that way) would allow hierarchically inspecting the output at the desired detail level. The article shows nested overload candidates that could be potentially be collapsed, for example.
IshKebabMay 21, 2026
Wow I never thought I'd see GCC innovating with error messages!

I looked into using SARIF once before and found it's an enormous over-engineered design-by-committee spec, but I guess it's still better than regexes (do people really do that?).

pjmlpMay 21, 2026
So far it seems the best experience that we can kind of have is with VC++, because they use it on the errors section and you can kind of graphically navigate it, however the overall experience is still not out of this world.
crestMay 21, 2026
If you want to know how bad it take your time with GCC 4.x before they responded to clang. GCC error messages used to be horrible for anything but the most trival errors. A single C++ template error could span multiple screens and still not tell you the location.
rwmjMay 21, 2026
GCC has been innovating for a while with dmalcolm's -fanalyzer stuff.
whimblepopMay 21, 2026
SARIF is kinda nice for security-oriented linters imo, since lots of tools know how to speak it. It avoids lock-in that way, which is otherwise/previously pretty common, with every scanning tool using its own bespoke format.
account42May 21, 2026
I'm unsure if the error message change is actually a good thing. IME the main problem with template error messages is not that they are unreadable but just the sheer amount of them you can get from a simple error which makes it hard to find the root cause among the log spam - making the trace even more verbose will not help that.
bluGillMay 21, 2026
Yeah, the example was trivially short. Only one candidate that didn't match. Last time I had a template error the complete compiler output was too large for my scroll back buffer. (4-5 errors, but each repeated in dozens of places). I really want to see the difference in more realistic cases.