diff --git a/source/basic.tex b/source/basic.tex index 0f0473e3d9..df7f95fefc 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -3207,6 +3207,8 @@ \end{note} \begin{example} \begin{codeblock} +// assumes that \tcode{sizeof(int)} is equal to 4 + template struct AlignedUnion { alignas(T...) unsigned char data[max(sizeof(T)...)]; @@ -3221,7 +3223,7 @@ struct A { unsigned char a[32]; }; struct B { unsigned char b[16]; }; -A a; +alignas(int) A a; B *b = new (a.a + 8) B; // \tcode{a.a} provides storage for \tcode{*b} int *p = new (b->b + 4) int; // \tcode{b->b} provides storage for \tcode{*p} // \tcode{a.a} does not provide storage for \tcode{*p} (directly),