This program:
struct alignas(4) foo {};
int main() { return sizeof(foo); }
returns 4, with GCC 10.1 and clang 10.1, and icc 19.0.1 .
That makes me wonder - is it mandatory for alignas()
to affect sizeof()
this way? i.e. increase the size beyond what the structure would originally be sized at? Or - is this change just the implementation's prerogative?
foo f[10];
do if it wouldn't affect the size that way? – Saccule