Skip to content

MSVC Compatibility: [[msvc::no_unique_address]] doesn't work in a base class #143245

Open
@mingxwa

Description

@mingxwa
struct A {};

struct B {
  [[msvc::no_unique_address]] A val;
};

struct C : B {
  char x;
};

static_assert(sizeof(C) == 1);  // clang-cl thinks sizeof(C) is 2, while it should be 1

When the standard [[no_unique_address]] is used in regular mode, the memory layout of C is expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partydiverges-from:msvcDoes the clang frontend diverge from msvc on this issueextension:microsoft

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions