on-internet
← Community

Why does [[no_unique_address]] interfere with base classes in MSVC?

Stack Overflow ·

The following program returns 1 on all compilers except MSVC, where it returns 2: struct E1 { }; struct E2 { }; struct #ifdef _MSC_VER __declspec(empty_bases) // This doesn't make any difference #endif S : E1 { char c; [[no_unique_address]] #ifdef _MSC_VER [[msvc::no_unique_address]] #endif E2 e; }; int main() { return sizeof(S); } Why is this? Shouldn't no_unique_address cause e and c to overlap?

Comments

Sign in or sign up to comment and upvote.

No comments yet.