-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Support] Replace deprecated std::aligned_union, NFCI. #127417
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
Conversation
All std::aligned_* are deprecated in C++23. Implement the replacement suggested in P1413R3 using alignas and std::max.
|
@llvm/pr-subscribers-llvm-support Author: Jonas Hahnfeld (hahnjo) ChangesAll Full diff: https://github.com/llvm/llvm-project/pull/127417.diff 1 Files Affected:
diff --git a/llvm/include/llvm/Support/AlignOf.h b/llvm/include/llvm/Support/AlignOf.h
index f586d7f182aab..635bb8b101ef9 100644
--- a/llvm/include/llvm/Support/AlignOf.h
+++ b/llvm/include/llvm/Support/AlignOf.h
@@ -13,20 +13,14 @@
#ifndef LLVM_SUPPORT_ALIGNOF_H
#define LLVM_SUPPORT_ALIGNOF_H
-#include <type_traits>
+#include <algorithm>
namespace llvm {
/// A suitably aligned and sized character array member which can hold elements
/// of any type.
-///
-/// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot
-/// use it due to a bug in the MSVC x86 compiler:
-/// https://github.com/microsoft/STL/issues/1533
-/// Using `alignas` here works around the bug.
template <typename T, typename... Ts> struct AlignedCharArrayUnion {
- using AlignedUnion = std::aligned_union_t<1, T, Ts...>;
- alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)];
+ alignas(T) alignas(Ts...) char buffer[std::max({sizeof(T), sizeof(Ts)...})];
};
} // end namespace llvm
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/17695 Here is the relevant piece of the build log for the reference |
|
Hi, |
|
@jplehr I played a bit with Compiler Explorer and it seems the problem is |
|
I don't mind if you land and we see if it fixes the issue and we revert in case it does not. |
|
Pushed 6a5dd04, fingers crossed 🤞 |
|
Looks good. Thank you for that quick fix! |
All
std::aligned_*are deprecated in C++23. Implement the replacement suggested in P1413R3 usingalignasandstd::max.