r/C_Programming • • Jul 30 '26

Memory layout primitives

https://napcakes.nekoweb.org/posts/blayout/
40 Upvotes

12 comments sorted by

View all comments

Show parent comment

2

u/skeeto Aug 04 '26

For the record this started with GCC 15, and it's listed in the changelog here:

https://gcc.gnu.org/gcc-15/changes.html#c

Some new features from the upcoming C2Y revision of the ISO C standard are supported with -std=c2y and -std=gnu2y. Some of these features are also supported as extensions when compiling for older language versions.

At the very least "Accessing byte arrays" and "Allow zero length operations on null pointers" are always well-defined starting in GCC 15 regardless of the -std= flag. I knew this was true for the latter because I've already taken advantage of it, but I checked now and it applies to the former, too. Not surprising since both have already been well-defined in C++ for some time now.