GCC 14 is still in development, but it has a wonderful new feature in its static analyzer (-fanalyzer).

It can now draw beautiful Unicode diagrams showing exactly how you went out-of-bounds.

See https://inbox.sourceware.org/gcc-patches/[email protected]/ too.

Thank you to the wonderful David Malcolm for implementing this - who also does a tonne of work with mentoring for GCC's GSoC programme, and working on docs to help new people get into GCC: https://gcc-newbies-guide.readthedocs.io/en/latest/index.html.

@gnutools

[PATCH 0/3] Add diagram support to gcc diagnostics - David Malcolm

I should also say that if you want a distribution that makes it very easy to have multiple GCCs installed at once and is recognised for its high-quality toolchain maintenance, you know where we are 😉

#gentoo

@thesamesam @gnutools

For all the people who still held any illusions that they are good at writing C:

"Look, human. This is where your weird human brain decided to introduce a fence-post error again.
Here, I have drawn you a picture. Sorry, crayons were out." 

@thesamesam @gnutools oh awesome ... can't wait to try this out with gdb.
@thesamesam @gnutools That's David Malcolm's work! I wish we could clone him!
@egallager @gnutools A genuinely outstanding asset to GCC! I meant to name him in the post, and I'll edit it to now as well.
@thesamesam @gnutools About time they use Unicode. It even uses emoji!
@thesamesam @gnutools the shown example is an overread of 2 bytes though (read of one byte, one past end of the object)
@thesamesam @gnutools this looks absolutely fantastic

@thesamesam @gnutools I won’t pretend to really understand this, but I just have to say:

IT LOOKS SO COOL. Plus, visualizing things can greatly help folks who process better visually, so I’m a huge fan!

@thesamesam @gnutools

Counting seems to be a bit off. Why it says "out-of-bounds read at byte 3" for simpsons_quotes[3]?

That is byte 4 and therefore the offset is 2 bytes and not just one as @mirabilos mentioned it too.

@thesamesam Reminds me of it being a thing where clang prints a warning but which scan-build ignores…

$ scan-build clang /tmp/foo.c -o /tmp/foo
scan-build: Using '/usr/lib/llvm/16/bin/clang-16' for static analysis
/tmp/foo.c:5:20: warning: format specifies type 'char *' but the argument has type 'char' [-Wformat]
printf("bar: %s", foo[3]);
~~ ^~~~~~
%c
/tmp/foo.c:5:20: warning: array index 3 is past the end of the array (that has type 'char[2]') [-Warray-bounds]
printf("bar: %s", foo[3]);
^ ~
/tmp/foo.c:4:2: note: array 'foo' declared here
char foo[2] = "a";
^
2 warnings generated.
scan-build: Analysis run complete.
scan-build: Removing directory '/tmp/scan-build-2023-07-14-041437-3476-1' because it contains no reports.
scan-build: No bugs found.

@thesamesam @gnutools

That’s a nice font, mind sharing its name?

@fmeyer @gnutools This is the wonderful Berkeley Mono from https://berkeleygraphics.com/typefaces/berkeley-mono/.

It's absolutely worth it.

Berkeley Mono Typeface

A love letter to the golden era of computing.

Berkeley Mono Typeface

@thesamesam @gnutools

Indeed, I remember now; I downloaded the beta but never committed to it. I'll give it another try since I'm a bit frustrated with Iosevka ambiguities.

Funny enough, it's perfect for my blog thing so I just snapped a licence :D

@thesamesam @gnutools My favorite thing about this is the error message arms race that seems to be going on between compilers! I always thought Rust started it, but then I remembered that Rust got a lot of its inspiration for nice error messages from Clang saying "undefined identifier X, did you mean Y" where Y is spelled similarly to X.

Anyway, this looks like super cool functionality!

@thesamesam can't believe they're rewriting C compilers in rust /j
@thesamesam @gnutools I literally screamed "Holy Shit"
@thesamesam @gnutools oh nice. I have to read through that guide!
@thesamesam
I only read this toot and already i love this feature!
@gnutools