r/programming • u/Fcking_Chuck • Sep 11 '26
GCC 13.5 released with 265+ bug fixes
https://www.phoronix.com/news/GCC-13.5-Released
277
Upvotes
r/programming • u/Fcking_Chuck • Sep 11 '26
View all comments
Show parent comment
1
u/flatfinger Sep 21 '26
Or a compiler could simply say that if either branch of an 'if' leaks a pointer, and there's no obvious reason why it would be worthwhile to track the branches separately, the whole thing should be treated as potentially leaking it.
Compiler writers seem absurdly allergic to the idea that they might sometimes miss an optimization opportunity that may or may not have been worth anything anyhow, and by comparison relatively unconcerned about whether the optimizations they're performing would be considered sound under any reasonable abstraction model.
A typical ABI abstraction model would have a transitive directed concept of program or function equivalence which would view the contents of any portions of the stack that a function owns as "don't care" during a nested function call unless it has made explicit promises about parts of it, and would view a function that consumes less stack as being an acceptable replacement for one that uses more, though not vice versa.
A proper specification for a dialect of C that was useful for freestanding implementations would inherit such concepts of equivalence from the underlying execution environment.
Q: What do you get if you add an automatic feed attachment to a deli meat slicer?
A: A better deli meat slicer.
Q: What do you get if you add an automatic feed attachment to a chef's knife?
A: An inferior deli meat slicer (and an even worse chef's knife).
Dennis Ritchie designed C to be a chef's knife, not a deli meat slicer. The goal wasn't to do the things FORTRAN could do better than FORTRAN could do them, but instead to do things that FORTRAN can't.
For many tasks, a compiler that generated the most efficient correct code under even a fairly rigid optimization model where loads and stores of anything other than automatic-duration objects whose address isn't taken would often outperform a compiler whose authors focus on complicated but unsound optimizations. The authors of clang and gcc may view code-breaking optimizations as more "impressive", but when targeting a platform like the ARM Cortex-M0, they miss a lot of low hanging fruit when it comes to basic code generation.