Usability Improvements in GCC 15

https://news.ycombinator.com/rss Hits: 14
Summary

I work at Red Hat on GCC, the GNU Compiler Collection. I spent most of the past year working on how GCC emits diagnostics (errors and warnings) in the hope of making it easier to use. Let's take a look at 6 improvements to look forward to in the upcoming GCC 15.1. Prettier execution pathsI added a static analyzer to GCC in GCC 10 that prints visualizations of predicted paths of execution through the user's code, demonstrating each problem it predicts.Here's an example that shows some of the improvements I've made to this in GCC 15:infinite-loop-linked-list.c: In function ‘while_loop_missing_next’: infinite-loop-linked-list.c:30:10: warning: infinite loop [CWE-835] [-Wanalyzer-infinite-loop] 30 | while (n) | ^ ‘while_loop_missing_next’: events 1-3 30 | while (n) | ^ | | | (1) ⚠️ infinite loop here | (2) when ‘n’ is non-NULL: always following ‘true’ branch... ─>─┐ | │ | │ |┌────────────────────────────────────────────────────────────────────────┘ 31 |│ { 32 |│ sum += n->val; |│ ~~~~~~ |│ | |└─────────────>(3) ...to here ‘while_loop_missing_next’: event 4 32 | sum += n->val; | ~~~~^~~~~~~~~ | | | (4) looping back... ─>─┐ | │ ‘while_loop_missing_next’: event 5 | │ |┌─────────────────────────────────┘ 30 |│ while (n) |│ ^ |│ | |└────────>(5) ...to here I've added a warning emoji (⚠️) to the event in the path where the problem occurs (event 1 in the above), and I've added "ASCII art" to show control flow, such as the lines connecting events 2 and 3, and those connecting events 4 and 5 (compare with the GCC 14 output seen here).Another example of an execution path can be seen in this new -fanalyzer warning -Wanalyzer-undefined-behavior-ptrdiff, which warns about pointer subtractions involving different chunks of memory:demo.c: In function ‘test_invalid_calc_of_array_size’: demo.c:9:20: warning: undefined behavior when subtracting pointers [CWE-469] [-Wanalyzer-undefined-behavior-ptrdiff] 9 | return &sentinel - arr; | ^ events 1-2 │ │ 3 | int arr[42]; │ | ~~~ │ | | │ | (2) ...

First seen: 2025-04-10 15:44

Last seen: 2025-04-11 04:47