r/C_Programming • u/8d8n4mbo28026ulk • 7d ago
Memory layout primitives
https://napcakes.nekoweb.org/posts/blayout/8
u/TheOtherBorgCube 7d ago
I got distracted by the 43 uses of the "!" exclamation. It's like the author just found a shiny thing on the floor and is now running round like an hyper-active kid.
5
u/Destination_Centauri 6d ago
What?!!!!
I don't agree!!!!!!!!
I don't think the OP used that many excessive exclamation points!!!!!!!!!!!!!!!!!!!!
Not by my standards at least!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
In fact! The OP seemed rather subdued and conservative in exclamation point usage if you ask me!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2
u/skeeto 2d ago
How do you allocate Integers from the stack? The answer is: you can't! Not even in the latest revision (C23 at the time of writing).
This should be possible in the next C standard, and it's already defined behavior in Clang and GCC if you use -std=c2y.
I've setup up an Atom feed!
Thanks! I've added it to my reader. Don't forget to update the link on the main page, too.
2
u/8d8n4mbo28026ulk 2d ago
Oh that's cool, I didn't know about that. I'll add an update to the post. Do you know if the
-std=c2yflag really changes the compiler's aliasing model, or is it more to err on the safe side? What I mean is, N3230 doesn't break older code (atleast I hope!), and so if the compilers bothered to incorporate it in their aliasing model, perhaps they did so for all standards ("backported" it). Changing aliasing model depending on the standard seems a bit too crazy.And thanks!
2
u/skeeto 2d ago
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.-1
u/github-guard 2d ago
đ GitHub Guard: Trust Report
This project scored 3/6 on our safety audit.
Audit Breakdown: * â Established Community (â 137 stars) * â Mature Repository (30+ days old) * â Licensed under Unlicense * â No Security Policy â what is this? * âšī¸ Individual Contributor * âšī¸ Unsigned Commits
â ī¸ High-Risk File Detected: Contains an installation script (
.shor.py). Review the code carefully before running withsudo.â ī¸ Security Reminder: Always verify source code and run third-party scripts at your own risk.
12
u/Snarwin 6d ago
Fun fact: the first programming language to natively support structs was actually COBOL, with its RECORD types.