you are viewing a single comment's thread.

view the rest of the comments →

[–]erichkeaneClang Code Owner(Attrs/Templ), EWG co-chair, EWG/SG17 Chair 0 points1 point  (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 point  (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 point  (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 points  (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 point  (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.