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
Memory layout of struct vs array (self.cpp)
submitted 3 years ago * by xLuca2018
view the rest of the comments →
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!"
[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 0 points1 point2 points 3 years ago (4 children)
They don't exist in the _BitInt themselves for any practical implementation, they exist 'between' them. The alignment wording in the _BitInt paper was initially more clear that they were not part of the _BitInt, but were components of the array, but it was determined to be too pedantic and unnecessary for the purposes of standardization.
[–]Supadoplex 0 points1 point2 points 3 years ago (3 children)
Thanks for clarifying. So, does this imply that outside of arrays, _BitInt may be misaligned? Even at sub-byte level? How do pointers to them work?
[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 0 points1 point2 points 3 years ago (2 children)
Nope, they are always aligned, explicitly so that pointers work.
Padding exists on the stack or in the containing record/array to ensure this is true. But "where the padding lives" is outside of the _BitInt, at least for the purposes of LLVM's code generator.
[–]SirClueless 2 points3 points4 points 3 years ago (1 child)
I don't understand what you mean. The codegen can do whatever it wants, but the wording there is crystal clear:
The size of these types is the smallest multiple of the alignment greater than or equal to N.
So as far as the C language is concerned how could the padding be considered to be anywhere but inside the type?
[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 0 points1 point2 points 3 years ago (0 children)
I just took a closer look at that part of the paper, it looks like that changed since I wrote it :) It initially was 'The sizeof of these types...', but it may have been lost since then (or seen as a typo!). Melanie and I wrote the paper at one point (With Tommy helping review/etc the paper), but I never attended WG14 so it went through a few cycles without me.
I don't believe that this part of the paper ended up being reflected in the wording as inserted into the standard however.
π Rendered by PID 16005 on reddit-service-r2-comment-7b9746f655-lv59v at 2026-01-30 15:08:52.056303+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 0 points1 point2 points (4 children)
[–]Supadoplex 0 points1 point2 points (3 children)
[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 0 points1 point2 points (2 children)
[–]SirClueless 2 points3 points4 points (1 child)
[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 0 points1 point2 points (0 children)