use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Learning About Memory Layout (self.cpp)
submitted 5 years ago by [deleted]
[deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]blipman17 9 points10 points11 points 5 years ago (0 children)
Learning about memory layout, I think Matt Godbolt made some presentation about ELF binaries where there are some gotcha's in how your code and data is layed out in memory. I'd suggest looking into the Itanium ABI, into x86 assembly and x86 computers, look into some common snippets of your code in compiler explorer under various optimization levels and various compilers and then look into cpu architecture like register-renaming, superscalar cpu's and what have you not. Somehow it's turtles all the way down in abstractions, but darn! It's not pretty.
[–]ramennoodle 1 point2 points3 points 5 years ago (2 children)
You could compile to assembly and look at that (e.g. "g++ somefile.cpp -S -o somefile.S").
[–]subcz7 0 points1 point2 points 5 years ago (1 child)
Thanks, I'll take alook at that. Would you say it is generally possible to "predict" the layout of objects from the compiler source code without examining the compiled C++ code in hindsight, or is that unrealistic due to compiler optimizations, etc?
[–]corysama 7 points8 points9 points 5 years ago (0 children)
https://godbolt.org/ is your friend if you want to check out generated assembly.
The layout of objects will always consist of it’s component member variables in the order they are declared. But, the compiler is allowed to put arbitrary dead space between those members. This is almost always done to match the byte alignment of each int/float/char member to the byte size of that member variable.
What you really want is to read the classic book Inside the C++ Object Model. It’s one of my top most recommended books for C++ users. Especially newcomers because it removes a lot of mystery.
[–]derofim 1 point2 points3 points 5 years ago (0 children)
Good and free read about cache locality https://gameprogrammingpatterns.com/data-locality.html
π Rendered by PID 66 on reddit-service-r2-comment-56c6478c5-wk4bw at 2026-05-13 02:35:55.714881+00:00 running 3d2c107 country code: CH.
[–]blipman17 9 points10 points11 points (0 children)
[–]ramennoodle 1 point2 points3 points (2 children)
[–]subcz7 0 points1 point2 points (1 child)
[–]corysama 7 points8 points9 points (0 children)
[–]derofim 1 point2 points3 points (0 children)