-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Bogus warnings: warning: 'allocator<void>' is deprecated #49643
Comments
assigned to @ldionne |
For added fun, you have a potential ABI break: #include This passes in C++17 and earlier, but not in C++20: a.C:5:1: error: static_assert failed due to requirement 'std::is_trivially_default_constructible::value' "" Your primary template for std::allocator has a non-trivial default constructor (for C++03 compat, just like GCC's one does) and so when allocator uses the primary template, it also has a non-trivial default ctor. In C++17 the explicit specialization for allocator has a trivial default ctor. I don't know if you care about this case. |
This was even called out in "Removing the explicit specialization, per the proposed resolution below, should no impact on that, as the primary template will now provide the correct behavior." The intention is that allocator continues to be usable by programs, all that changes is how the library defines it. And so giving users a diagnostic is wrong. |
You're right, but for our defence, https://wg21.link/p0174#2.2 did deprecate the specialization, and I'm not seeing any discussion saying something like "but oh, users should still be able to use it". The intent appears to be pretty unclear if you read only that paper, and you actually need to read the fine print in wg21.link/p0619r4#3.9 to know the intent. Am I missing something or that's messed up? |
I think that is unlikely to bite anyone. |
I'm also trying to backport this to LLVM 12.0.1 because I think this is a pretty vexing issue: https://reviews.llvm.org/D104324 |
commit 87784cc
|
I also created a patch for fixing the triviality difference between C++20 and previous standard modes at https://reviews.llvm.org/D104398. |
The fix does not apply cleanly, could someone backport this and push a branch to their local github fork? |
This has already been merged to commit e7dac56
|
I'm a bit confused. Isn't Table 35 saying that in order for |
Extended Description
This warning is misleading and unhelpful. It's true that the explicit specialization is deprecated in C++17 and gone in C++20, but that doesn't mean users can't use
std::allocator<void>
in C++20. It just means that doing so uses the primary template.It's perfectly fine to use std::allocator in C++17 in limited ways (e.g. you can't use it to allocate, obviously) and it's perfectly fine to use it in the same ways in C++20. Telling users it's deprecated is totally unhelpful, because they don't need to stop using it, but they can't do anything about the warnings except to stop using it.
What purpose do the warnings serve? What do you expect users to do if they get that warning? Why should they change their code, when there's nothing wrong with it?
Please revert the additions of the deprecated attributes here.
The text was updated successfully, but these errors were encountered: