Closed
Description
Bugzilla Link | 50014 |
Version | trunk |
OS | Windows NT |
Attachments | test.cpp: the source file that triggers the warning. log.txt: console output from compiling test.cpp. |
CC | @AaronBallman,@CaseyCarter,@Ivan171,@zygoloid |
Extended Description
https://clang.llvm.org/cxx_status.html#cxx20 lists the [[no_unique_address]] attribute as supported since Clang 9. However, the attribute does not seem to currently be supported on Windows platforms.
Compiling the following source code on Windows with Clang 12.0.0 with -std=c++20:
struct X {};
struct Y1 {
[[no_unique_address]] X x;
long long a;
};
struct Y2 {
X x;
long long a;
};
int main() {}
gives the following warning:
test.cpp:4:4: warning: unknown attribute 'no_unique_address' ignored [-Wunknown-attributes]
[[no_unique_address]] X x;
^~~~~~~~~~~~~~~~~
1 warning generated.
The size of objects from Y1 are also the same size as those from Y2, indicating that an unique address is indeed still generated:
std::cout << sizeof(Y1) << ", " << sizeof(Y2);
prints "16, 16" compared to "8, 16" on Linux: https://godbolt.org/z/nfaf3KeP3
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done