Skip to content(if available)orjump to list(if available)

Usability Improvements in GCC 15

Usability Improvements in GCC 15

229 comments

·April 10, 2025

munificent

Using a hierarchy to show template errors is brilliant and I'm sort of surprised compilers haven't always done that.

I was investigating C++-style templates for a hobby language of mine and SFINAE is an important property to make them work in realistic codebases, but leads to exactly this problem. When a compile error occurs, there isn't a single cause, or even a linear chain of causes, but an potentially arbitrarily large tree of them.

For example, it sees a call to foo() and there is a template foo(). It tries to instantiate that but the body of foo() calls bar(). It tries to resolve that and finds a template bar() which it tries to instantiate, and so on.

The compiler is basically searching the entire tree of possible instantiations/overloads and backtracking when it hits dead ends.

Showing that tree as a tree makes a lot of sense.

pjmlp

Only if stuck in C++17 and earlier.

Past that point SFINAE should be left for existing code, while new code should make use of concepts and compile time execution.

eddd-ddde

I really wish templates didn't work on a dumb "replace at call site until something compiles" manner.

All template requirements should be verified at the function definition, not at every call site.

There is concepts. But they are so unwieldy.

munificent

It's honestly a seriously hard problem.

Yes, it's definitely nice to be able to typecheck generic code before instantiation. But supporting that ends up adding a lot of complexity to the typesystem.

C++-style templates are sort of like "compile-time dynamic types" where the type system is much simpler because you can just write templates that try to do stuff and if the instantiation works, it works.

C++ templates are more powerful than generics in most other languages, while not having to deal with covariance/contravariance, bounded quantification, F-bounded quantification, traits, and all sorts of other complex machinery that Java, C#, etc. have.

I still generally prefer languages that do the type-checking before instantiation, but I think C++ picks a really interesting point in the design space.

trashburger

Please no. Templates being lazy is so much better than Rust's eager trait evaluation, the latter causing incredible amounts of pain beyond a certain complexity threshold.

eddd-ddde

How so? I'd really like to see an example. If you can't explain what requirements your function has before calling it then how do you know it even does what you expect?

jenadine

C++0x concepts tried to achieve that but that didn't work.

(But Rust traits works like that)

pjmlp

There were lots of politics evolved, moreso than technical issues.

While not perfect concepts lite, alongside compile time evaluation do the job.

mwkaufma

Usability improvement request for this article: don't hijack the browser back button :P

bigstrat2003

Browser makers should straight up remove the JS API for interacting with history. There are legitimate uses for it, but the malicious actors far outweigh the good ones at this point. Just remove it.

jart

That's a biased thing to say, since you're never going to notice the times when the history api is being used appropriately. Just as often I find myself raging when a webpage doesn't rewrite history at times when it should. Good taste is hard to come by.

nightfly

This type of thinking is what doomed uBlock Origin. I strongly disagree.

jenadine

The difference is that uBlock Origin is an extension you intentionally trust and install, while the JS API we talk about are something any websites (untrusted) can use.

matheusmoreira

To be fair, uBlock Origin has always been a special case. It's so good and so important and so trusted that it should have access to browser internals that normal extensions can't access.

Honestly, uBlock Origin shouldn't be an extension to begin with, it should be a literally built in feature of all browsers. Only reason it's not is we can't trust ad companies to maintain an ad blocker.

goku12

Perhaps the users should be given an option to opt out (enabled by default) for such APIs on a per-site basis. That way, users can intervene when they're abused, while their fair use will remain transparent.

PaulDavisThe1st

How is uBlock Origin "doomed" ?

Dracophoenix

Ditto for unprompted redirects.

bonzini

Redirects are used for stuff like POST->GET or canonicalizing URLs (adding slashes on directories), would you get rid of that too?

TZubiri

But wouldn't you be able to replicate the same issue by using a redirect?

nullc

Ditto for rewriting anchor destinations onclick, allowing sites to show one destination for hover but send you somewhere else.

panzi

I mean, without `history.pushState()` and `window.onpopstate` things wouldn't be as nice. Ok, I guess one could do about everything with `location.hash = ...` and `window.onhashchange`, like in the before times. But the server will not get the hash part of the URL so a link to such an page can't be server side rendered and has to fetch the actual page content in JavaScript, evaluating the hash. When I browse things like image search it is really handy that you can use the browsers back button to close an opened image without loosing any dynamic state of the page and that the x button on the page will close the image and remove the history entry just the same way, so a later back won't re-open that image.

For me the back button wasn't hijacked.

But I am for disallowing the use of `history.go()` or any kind of navigation inside of `onpopstate`, `onhashchange`, `onbeforeunload` or similar or from a timer started from one of those.

bigstrat2003

Like I said: I recognize there are legitimate uses. But unfortunately, they are majorly outnumbered by people doing things like overwriting my history so that when I hit "back", it stays on the site instead of going back to my search engine. I would love to live in the world where malicious dark patterns didn't exist, and we could have nice things. But we don't, and so I would rather not have the functionality at all.

mort96

How about we just navigate to new pages by .. navigating to new pages? Browsers have perfectly functional history without javascript shenanigans

spookie

same for clipboard events.

optionalsquid

In Firefox, you can prevent this by setting `browser.navigation.requireUserInteraction` via about:config. I've been told that it breaks some stuff, but to date I haven't noticed any downsides

teddyh

> you can prevent this by setting `browser.navigation.requireUserInteraction`

Setting it to what?

budmichstelk

Doesn't answer your question, but in Tor Browser it would decrease your anonymity set.

llm_nerd

It's already egregious when a site adds history pushState entries for just clicking through a gallery or something, but wow adding them just for scrolling down on a page is simply bizarre, especially on a page about usability.

nottorp

It's in the spirit of adding emojis to compiler output...

ender341341

I actually quite like the emojis they put in the output, it helps alleviate the balance of providing enough context while also giving a clear visual indicator for the actual error message.

They aren't going overboard on it, they just put a warning emoji in front of the error message.

perching_aix

Not an issue with JS disabled ;)

null

[deleted]

DyslexicAtheist

Usability improvement request for this site: don't promote a comment that isn't related to the content to the top :P

TZubiri

works fine for me (MS Edge)

porphyra

With GCC error messages usually the only part I wanna see is "required from here" and yet it spams zillions of "note: ...". With the nesting enabled, it's way easier to read --- just look at the top indentation level. Hooray!!!

orlylol

[flagged]

jmclnx

I hope gcc remains the default in Linux due to the GPL. But I expect someday clang will become the default.

Plus I heard COBOL was merged in with the compiler collection, nice!

pxc

> I expect someday clang will become the default [compiler for the Linux kernel].

Why? I don't personally use GCC except to compile other people's projects in a way that's mostly invisible to me, but it seems like it's still widely used and constantly improving, thanks in part to competition with LLVM/Clang. Is the situation really so dire?

wahern

> Is the situation really so dire?

I for one don't think so. From my perspective, there's at least as much momentum in GCC as clang/LLVM, especially on the static analysis and diagnostics front over the past 5 or so years. That was originally one of the selling points for clang, and GCC really took it to heart. It's been 10 years since GCC adopted ASAN, and after playing catchup GCC never stopped upping their game.

Perhaps the image problem is that LLVM seems to be preferred more often for interesting research projects, drawing more eyeballs. But by and large these are ephemeral; the activity is somewhat illusory, at least when comparing the liveliness of the LLVM and GCC communities.

For example, both clang/LLVM and GCC have seen significant work on addressing array semantics in the language, as part of the effort to address buffer overflows and improve static analysis. But GCC is arguably farther along in terms of comprehensive integration, with a clearer path forward, including for ISO standardization.

More importantly, the "competition" between GCC and clang/LLVM is mutually beneficial. GCC losing prominence would not be good for LLVM long-term, just as GCC arguably languished in the period after the egcs merger.

pxc

> More importantly, the "competition" between GCC and clang/LLVM is mutually beneficial. GCC losing prominence would not be good for LLVM long-term, just as GCC arguably languished in the period after the egcs merger.

You're right to note that "competition" here is more like inspiration than a deathmatch. But I vaguely remember two things that seem similar to motivation via competitive pressure to me: (1) when GCC 5 came out, it had way nicer error messages, and I immediately thought "Oh, they wanted to make GCC nice like Clang" and (2) IIRC the availability of a more modular compiler stack like LLVM/Clang essentially neutralized Stallman's old strategic argument against more a more pluggable design, right?

ahartmetz

Clang:

- has about the same quality of error messages as GCC now

- is now almost exactly as slow (/fast) as GCC at compiling now

- sometimes produces faster code than Clang, sometimes slower, about the same overall

I see no reason why the default would change.

almostgotcaught

well for one clang uses way less memory (RAM). also ld.lld is wayyyyyyyy faster than ld (and also uses way less memory).

ahartmetz

ld.lld works with any compiler, and anyway, mold is even faster and also works with any compiler.

jklowden

Yup, COBOL is that overnight sensation 4 years in the making. GCC COBOL is foremost an ISO COBOL compiler, with some extensions for IBM and MicroFocus syntax. We also extended gdb to recognize COBOL, so the GCC programmer has native COBOL compilation and source-level debugging.

enasterosophes

Unless you're talking about a compiler built into the kernel, I don't see that anyone is in a position to dictate to each distro what compilers they package.

mort96

GCC can honestly only blame itself for its inevitable increasing obsolescence. LLVM only has the attention it has because it can be used as a building block in other compilers. GCC could've made a tool and library which accepts IR, performs optimizations and emits machine code, but the project avoided that for ideological reasons, and as a result created a void in the ecosystem for a project like LLVM.

aengelke

I'd add code quality as a reason. I find it much easier to understand and modify code in LLVM compared to GCC. Both have a fairly steep learning curve and not too much documentation, but often I (personally) find LLVM's architecture to be more thought out and easier to understand. GCC's age shows in the code base and it feels like many concepts and optimizations are just bolted on without "required" architectural changes for a proper integration.

pjmlp

The embedded compiler vendors, UNIX and consoles are quite happy with it.

How much do you think they contribute back upstream regarding ISO compliance outside LLVM backend for their hardware and OS?

mort96

Embedded compiler vendors and UNIXes want a possibly slightly patched C or C++ compiler, maybe with an extra back-end bolted on. I'm talking about use-cases like Rust and Zig and Swift, projects which want a solid optimizing back-end but their own front-end and tooling.

umanwizard

What exactly do you mean by "UNIX"? Commercial UNIX vendors other than Apple have basically a rounding error from 0% of market share.

bobmcnamara

Apple, Arm, OpenBSD, FreeBSD have all switched to Clang.

duped

It's not like GCC or the embedded toolchains are a shining beacon of ISO compliance... and if you mean video game consoles, are any of them using GCC today? Sony and Nintendo are both LLVM and Microsoft is Microsoft

codeshaunted

Is it still the case that the Linux kernel cannot be compiled using clang, or can you do that now?

bombcar

I believe clang has worked for years now.

homebrewer

https://static.lwn.net/kerneldoc/kbuild/llvm.html

I do remember reading about LTO not working properly, you're either unable to link the kernel with LTO, or get a buggy binary which crashes at runtime. Doesn't look like much effort has been put into solving it, maybe it's just too large a task.

LeFantome

There are a few distros that use Clang as the system compiler (SerpentOS and Chimera Linux for two).

Tpt

There is now libgccjit that aims at allowing to embed gcc https://gcc.gnu.org/onlinedocs/jit/

There is an alternative backend to rustc that relies on it.

aengelke

libgccjit is, despite its name, just another front-end for GIMPLE. The JIT-part is realized through compiling the object file to a shared library and using dlopen on this.

One big problem with libgccjit, despite its fairly bad compile-time performance, is that it's GPL-licensed and thereby makes the entire application GPL, which makes it impossible to use not just in proprietary use-cases but also in cases where incompatible licenses are involved.

dralley

Yet another reason why I'm not a fan of Richard Stallman.

Most of the decisions he made over the past 25 years have been self-defeating and led directly to the decline of the influence of his own movement. It's not that "the GCC project" avoided that for ideological reason, Stallman was personally a veto on that issue for years, and his personal objection led to several people quitting the project for LLVM, with a couple saying as much directly to him.

https://gcc.gnu.org/legacy-ml/gcc/2014-01/msg00247.html

https://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00...

(both threads are interesting reading in their entirety, not just those specific emails)

kstrauser

I think that's an unreasonable lens for viewing his work. Of course he values purity over practicality. That's his entire platform. His decision making process always prioritizes supporting Free Software over proprietary efforts, pragmatism be damned.

Expecting Stallman to make life easier for commercial vendors is like expecting PETA to recommend a good foie gras farm. That's not what they do.

JoshTriplett

Don't forget that the LLVM folks actually went to GNU and offered it to them, and they failed to pay attention and respond. (It's not even that they responded negatively; they just dropped it on the floor completely.) There's an alternate history where LLVM was a GNU project.

With the benefit of hindsight, I'm glad that that didn't happen, even though I have mixed feelings about LLVM being permissively licensed.

cherryteastain

Without GNU, GPL and Richard Stallman, FOSS would not exist in the first place. The GPL forced companies to make FOSS a thing, whether they liked it or not.

knowknow

Kind like how GPL 3 makes it infeasible for most companies to use/support free software. At least Stallman gets to feel morally superior though

codeshaunted

Big fan of all of this except for the emojis in my console

Karliss

Few versions ago GCC added `-fdiagnostics-text-art-charset=[none|ascii|unicode|emoji]` so feel free to disable them.

https://godbolt.org/z/bYc7EqYWE

staplung

On the one hand I feel like the #WARNING_SIGN is a welcome addition. On the other, I'm sensitive to the idea that it will be totally obnoxious if you need to grep/search for it in whatever tool you're using.

Was a little surprised to learn that the warning sign is generally considered an Emoji; I guess I don't think of it that way. Was even more surprised to learn that there is no great definition for what constitutes an Emoji. The term doesn't seem to have much meaning in Unicode. The warning sign - U+26A0 - goes all the way back to Unicode version 4.0 and is in the BMP, whereas most Emoji are in the SMP.

Someone

> Was even more surprised to learn that there is no great definition for what constitutes an Emoji. The term doesn't seem to have much meaning in Unicode

The definition is messy, but the list of Unicode emojis is defined. Starting points: https://www.unicode.org/reports/tr51/, https://unicode.org/emoji/charts/full-emoji-list.html

codeshaunted

How will it output on my VT100 serial terminal? :P

Somewhat related fun fact, anyone can submit an emoji to the Unicode Consortium annually, submissions are actually open right now: https://unicode.org/emoji/proposals.html.

bonzini

It's only an emoji if followed by the "emoji presentation selector" U+FE0F. Without it, it has no colors (but hackernews doesn't allow including it).

pxc

If you're using an OS that honors your font choices (i.e., not macOS), you can use a font like Symbola to provide emoji so that they're stylized, monochrome, and vectorized, rather than incongruous color bitmap images. That helps them play nice with terminal colorschemes and things like that.

I'm not aware of any emoji fonts like Symbola which provide a monospace typeface, though. That would be a great option.

lyorig

By honoring font choices, do you mean the ability to overwrite emojis as well? I’ve never had issues using custom/nerd fonts, but it’s true that the emojis have stayed true to the Apple style so far.

pxc

Indeed. Emoji are just characters, rendered via some font just like any text character. On non-Apple operating systems, you can select emoji sets via font configuration.

You can do it on macOS as well, but you have to disable SIP and modify/replace the files for the Apple Color Emoji font, because some widely used GUI libs are hardcoded to use it.

Idr the situation on Windows except that emoji glyphs are inherited from your other font choices, if your chosen font includes emoji. But on Linux it's generally easy to configure certain font substitutions only for some groups of characters, like emoji.

guenthert

I actually appreciate a #\WARNING_SIGN, but then, why is there no #\STOP_SIGN ?

dlachausse

It should be easy to patch out or possibly add a command line switch to disable it if desired.

cassepipe

Already exists : -fdiagnostics-text-art-charset=[none|ascii|unicode|emoji]

high_na_euv

Why?

codeshaunted

Makes me feel like I'm writing JavaScript, if that makes any sense. Also I hate fun.

umanwizard

Well, other than the fact that it's hard to search for, things should be kept as simple as possible to improve reliability/interoperability. Are you confident that multi-column-wide non-ASCII characters work reliably without causing rendering issues on every possible combination of terminal/shell/OS, including over SSH? I'm certainly not.

gpderetta

You can already put multi-column-wide non-ASCII characters in your source code, so the horse has left the barn already.

aseipp

They are quite easy to search for actually, because they are sparse and you tend to not get so many spurious results due hitting things that contain your query as a substring. Even then, the glyphs appear inline in the warning message, they are not the anchor, you could still just search for "warning:" like you or your editor have been doing for years. Every operating system comes with an emoji picker, it takes like 2 seconds to use. I'm not sympathetic, tbqh.

dzaima

If anything, an emoji is easier to search for, as less things would be using it than a general "warning" (or whatever would make sense, as the emoji'd thing isn't the warning itself). Do have to get a copy from somewhere to search for though. It's also much easier to "visually" search for it.

At least in the blog there are a two spaces after the emoji so it can freely draw past its boundaries rightwards without colliding with anything for a good bit; and nothing to its right is used assuming monospace alignment. So at worst you just get a half-emoji.

javier_e06

I started putting emoji's in my bash scripts.

gitk broke! Can't parse emojis

I want emojis in my code. They are a superior form of communication (non-linear)

nomel

> I want emojis in my code.

Then you will enjoy swift [1]!

[1] Emoji driven development: https://www.swiftbysundell.com/special/emoji-driven-developm...

levodelellis

Please gcc, let me have a `~/.config/gcc` config file or an ENV variable so I can ask for single lined error messages.

I literally do not need ascii art to point to my error, just tell me line:col and a unique looking error message so I can spend no more than 1 second understanding what went wrong

Also allow me to extend requires with my own error messages. I know it'll be non standard but it would be very nice tyvm

meisel

The template error messages look great. I wonder if it’s worth writing a translator from clang/gcc messages to these ones, for users of clang and older gcc (to pipe one’s error messages to)

charcircuit

I mean why not show a proper image instead of doing fancier ASCII art. Or skip it entirely and have an LLM describe the issues and fix it for you.

kazinator

I can't imagine a piece of software easier to use than gcc 3.4.6, sorry.

We are now entering a Rococo period of unnecessarily ornate compiler diagnostics.

Getting these elaborate things to work is a nice puzzle, like Leetcode or Advent of Code --- but does it have to be merged?

Night_Thastus

I'm all up for better error messaging. :)

Can't use Clang where I'm at, but I do get to use fairly cutting-edge GCC, at least for Windows development. So I may get to see these improvements once they drop into MSYS.

bmn__

The writer David Malcolm tells a story in his article about compiling C17 code and pretending it's C23. Duh, no wonder it breaks!

You C standard authors have it bass-ackwards. The version of the code must accompany the code, not the compiler invocation.

taschenorakel

Why all this waste in Unicode art that nobody will ever see and that confuses your IDE.

Why not spend time on helping IDEs to understand error messages? That would be billion times more useful.

brcmthrowaway

What is the status of GCC plugins?

o11c

Is there any reason to ask this? GCC plugins have been good since 4.8. 4.5 lacked some essential features; 4.6 would be fine if not for the annoyance of trying to support a plugin that works across the C++ transition. Of course, you can just use the Python plugin to save yourself a lot of sanity ...

aseipp

They work. You can use them? They haven't gone anywhere and the Linux kernel relies on them extensively, among other things.