-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use [[no_unique_address]] after Clang supports it on Windows #1364
Comments
When targeting MSABI Clang emits unknown attribute warnings for
I would guess that work on this will be blocked on access to an MSVC that implements |
I recall first reinventing and then reusing existent compressed pair for |
MSVC has implemented |
@StephanTLavavej can plain struct S1 {};
struct S2 {};
#if defined(_MSC_VER)
#pragma warning(disable:4848)
#define _NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
#else
#define _NO_UNIQUE_ADDRESS [[no_unique_address]]
#endif
struct S
{
_NO_UNIQUE_ADDRESS S1 s1;
S2 s2;
};
int s()
{
return sizeof(S);
} |
@fsb4000 obseved that on Windows Clang does not support |
FYI, https://reviews.llvm.org/D110485 to support no_unique_address for Windows targets -- which, indeed, is blocked on concern of ABI incompatibility with MSVC. I can't tell if there's some other outcome (besides Clang continuing to ignore it on windows for now) which would be desirable -- if so, might be nice to chime in! |
Based on observing various MSVC versions, while newer versions of MSVC (since 16.9) do support |
That is precisely the intended behavior. We were concerned about interjecting |
Thanks for the clarification! |
|
If VS can be updated to use Clang 18 before C++23 ABI lockdown, it seems possible to use |
Seems doable now. Although it's somehow inconsistent that EDG recognizes |
Oops. Something is wrong for empty bases (Godbolt link), which is critical for views which use CRTP. template<class D>
struct CrtpBase {};
struct Empty {};
struct X : CrtpBase<X> {
int n;
[[msvc::no_unique_address]] Empty e;
};
static_assert(sizeof(X) == sizeof(int)); // OK with Clang, failed with MSVC
struct Y : CrtpBase<Y> {
[[msvc::no_unique_address]] Empty e;
int n;
};
static_assert(sizeof(Y) == sizeof(int)); // Both OK Is this DevCom-10588147? |
Yes it is. The fix should ship in VS 2022 17.12p3. |
VS 2019 16.9 will support
[[no_unique_address]]
. Clang lists this as supported in Clang 9. However, we suspect that it is not yet supported when Clang targets Windows, because MSVC didn't support it. So, #1363 is commenting out all of our[[no_unique_address]]
usage.[[no_unique_address]]
on Windows. (Clang does not.)[[no_unique_address]]
for C++20-only code.The text was updated successfully, but these errors were encountered: