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 #4806

Closed
StephanTLavavej opened this issue May 26, 2022 · 1 comment · Fixed by #5183
Closed

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

StephanTLavavej opened this issue May 26, 2022 · 1 comment · Fixed by #5183
Assignees

Comments

@StephanTLavavej
Copy link

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.

I searched and one line of affected code appears to be (there may be more):

typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type

(This emitted a warning when used by https://github.com/google/swiftshader , the project we built in our test harness.)

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.

@kuhar
Copy link
Contributor

kuhar commented Jul 4, 2022

Thanks for the heads up, @StephanTLavavej!

alignas seems to be available since C++11, so we should be able to switch to it.

Temporarily assigning Steven who authored this code.

s-perron added a commit to s-perron/SPIRV-Tools that referenced this issue Mar 29, 2023
s-perron added a commit to s-perron/SPIRV-Tools that referenced this issue Apr 5, 2023
Keenuts pushed a commit that referenced this issue Apr 6, 2023
* Remove use of deprecated std::aligned_storage

Fixes #4806.
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

Successfully merging a pull request may close this issue.

3 participants