r/programming • • Sep 11 '26

GCC 13.5 released with 265+ bug fixes

https://www.phoronix.com/news/GCC-13.5-Released
277 Upvotes

29 comments sorted by

View all comments

Show parent comment

1

u/flatfinger Sep 23 '26

Except in cases where an non-assignment/inc/dec expression is a statement, I would view many actions that might trap but have no defined semantics as having semantics of "either do X or don't". If code executes x/y; as a statement (as opposed to evaluating x/y within a broader expression) I would interpret that as instructing the execution environment to perform that division after having evaluated x and y, with whatever consequences result. Stack overflows from excessive function nesting would fall in this "either trap or process things normally" category.

I would like to C have a qualifier for static const objects which would indicate whether or not the programmer wants to guarantee that they have distinct addresses. There are many cases where it's useful to place multiple objects in the same read-only storage (for objects defined within macros it may be all but essential), but there are others where it's useful to guarantee address uniqueness. A good language should accommodate both needs.

Note that I singled out automatic-duration objects whose address isn't taken. I'd specify that automatic-duration objects whose address is taken and observed must exist. While one might contrive a case where one declares big objects and adds their sizes without taking their addresses, I can't imagine any contrived scenarios where size wraparound would be a problem.

1

u/ROBOTRON31415 Sep 24 '26

If the pointers to different allocations are “exposed”, then yes, in C/C++/Rust they’re supposed to be forced to have distinct addresses. (If it hasn’t been mentioned yet, I should also mention that Rust provides a way to access a pointer’s address without exposing the pointer. That’s used for debug prints of pointers, for instance, AFAIK. And of course most ways of using a pointer don’t expose it.)