Skip to content
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

std::aligned_storage is deprecated in C++23 #1063

Open
StephanTLavavej opened this issue May 26, 2022 · 0 comments
Open

std::aligned_storage is deprecated in C++23 #1063

StephanTLavavej opened this issue May 26, 2022 · 0 comments

Comments

@StephanTLavavej
Copy link
Contributor

I work on MSVC's C++ Standard Library, where we've recently implemented a C++23 paper that affects your project. (We regularly build many open-source projects to prevent compiler/library regressions, and this also allows us to notify projects of breaking changes that will affect them.)

The C++23 paper is https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1413r3.pdf "Deprecate std::aligned_storage and std::aligned_union". We've merged a PR (microsoft/STL#2583 ) that makes aligned_storage, aligned_storage_t, aligned_union, and aligned_union_t emit deprecation warnings when compiled in C++23 mode (/std:c++latest). This will be available in VS 2022 17.3 Preview 3. Although your project might not use /std:c++latest right now, we run such test coverage to identify issues that you might encounter in the future.

Examples of affected lines:

using std::aligned_storage;

typedef aligned_storage<
sizeof(asio::detail::shared_ptr<void>) + sizeof(void*),
alignment_of<asio::detail::shared_ptr<void> >::value
>::type object_type;

(These emitted warnings when used by the cpprestsdk project.)

In general, the recommended replacement is to use the alignas keyword. We do provide an "escape hatch" macro to silence the deprecation warning, if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant