ARTICLE AD BOX
This program fails to compile on MSVC. Why is this? Is this an intentional design choice or a bug?
#define NO_UNIQUE_ADDRESS [[no_unique_address]] [[msvc::no_unique_address]] struct S1 { struct {} e NO_UNIQUE_ADDRESS; }; struct S2 : S1 { struct {} e NO_UNIQUE_ADDRESS; }; struct S3 : S2 { struct {} e NO_UNIQUE_ADDRESS; }; int main() { static_assert(sizeof(S3) == sizeof(S1)); }213k133 gold badges565 silver badges935 bronze badges
2
Explore related questions
See similar questions with these tags.

the compiler may optimize it to occupy no space - "may" is not a requirement.
2026-01-26 04:33:59 +00:00
Commented 2 hours ago
This is MSVC, we can be fairly sure this is a bug.
2026-01-26 06:45:54 +00:00
Commented 14 mins ago