-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[libc++] no_unique_address
is reserved word in pre-C++20 dialects (non-conforming)
#61196
Comments
As per documentation: https://clang.llvm.org/docs/AttributeReference.html#no-unique-address this is supported in C++11 forward. I am looking at the PR: https://reviews.llvm.org/D63451 that implemented it and I don't see a rationale for supporting it as a extension in C++11. CC @zygoloid who implemented and can perhaps talk to why it is supported pre C++20 and attributes code owner @erichkeane |
I'm not sure I understand the question. It's clearly useful to support this in older versions, and it's conforming to do so. Indeed, the design of C++ attributes is intended precisely to permit compilers supporting attributes in older versions. There's definitely a libc++ bug here -- it's not conforming for it to use Now, Clang does support Presumably the proper fix for libc++ would be to guard this check with something like #if !defined(msvc) && !defined(no_unique_address) ... but I suppose there's still the possibility that the user will In any case, I don't see any Clang issue here. Retargeting as a libc++ bug. |
@zygoloid maybe I am reading it wrong but it seems like macro.names would reserve the attribute-tokens and by supporting it as a extension we are encroaching on the user namespace early then folks would expect. |
The attribute-token s are the standard attributes, i.e. you can't I think we should just remove the |
MSVC STL resolved this by preprocessor extensions (microsoft/STL#2649). Is the way suitable for libc++? |
We don't support the Microsoft compiler anyways, so we can just ask the clang folks to add an |
MSVC's approach is still broken: https://godbolt.org/z/cTYor9Ta6 It's also unsuitable for |
Reopening: the original issue reported here hasn't been fixed yet. |
…lify-attributes This adds a list of attributes which can be pretty to be able to reject attributes which were introduced in a later C++ standard. Fixes llvm#61196 Reviewed By: Mordante, #libc Spies: mikhail.ramalho, jdoerfert, libcxx-commits Differential Revision: https://reviews.llvm.org/D145508
…lify-attributes This adds a list of attributes which can be pretty to be able to reject attributes which were introduced in a later C++ standard. Fixes llvm#61196 Reviewed By: Mordante, #libc Spies: mikhail.ramalho, jdoerfert, libcxx-commits Differential Revision: https://reviews.llvm.org/D145508
I think I've roughly completed MSVC's approach (microsoft/STL#3760). If we apply that approach to libc++, there'll 35 files to be modified now (search result)... |
The attributes themselves are already _Ugly. The only thing that hasn't been fixed is when checking for attribute availability. |
However, when the non-_Uglified attribute token
|
As I said before, IMO Clang should just accept some _Ugly version of the msvc attributes. That's how it's done for gnu and clang attributes, and makes this all trivial to fix. |
@philnik777 we do not support the attribute at all (yet), so it is difficile to preemptively do that. and actually, we can't do that for any attributes we don't support as it is an open set |
Yes, I'm aware of that. I just meant that for any attribute that clang accepts it should also accept an _Ugly alias, since that doesn't look like a ton of effort to me for the compiler but makes the life of standard library maintainers so much easier. |
This is not a clang issue, the problem is in libc++. Clang changes won't help. |
Yes, this is a libc++ issue. But I don't want to push and pop macros all over the place once clang supports |
no_unique_address
is reserved word in pre-C++20 dialects (non-conforming)no_unique_address
is reserved word in pre-C++20 dialects (non-conforming)
Clang already supports that for all its attributes. The issue is that MSVC does not, so if we want to support MSVC, then that doesn't help us. If we don't want to support MSVC then we should just remove all the |
Agreed. TBH, @frederick-vs-ja solution of using pragma push seems like the best solution here. |
As we can see on this Godbolt link, even when compiling in earlier dialects than C++20 (such as C++17), we get a compiler error since
no_unique_address
is effectively a reserved word even in pre-C++20 dialects.Some context: Clang supports
[[no_unique_address]
in all dialects for C++11 and later (I don't know why it doesn't support it in C++03 mode, even as__attribute__((no_unique_address))
).Failing to support a double-underscored
no_unique_address
means thatno_unique_address
encroaches into the user's namespace in C++11 through C++17 dialects which is not good.One resolution would be if Clang could start supporting a __dundered form of
no_unique_address
that would be safely usable by the implementor, e.g.__attribute__((__no_unique_address__))
.The text was updated successfully, but these errors were encountered: