[cpp23] Remove use of std::aligned_storage in webrtc
std::aligned_storage is deprecated in C++23, see linked bug. The only webrtc usage (VoidUnion::inline_storage) employed the default Align parameter (i.e. std::aligned_storage<Len>, not std::aligned_storage<Len, Alignment>), which is defined as the largest alignment <= Len. This patch replaces the usage with a char buffer of same size and alignment alignof(std::max_align_t). In theory, this might increase alignment and use more memory. In practice, local testing in my machines showed no behavior change, since Len = kInlineStorageWords * sizeof(uintptr_t) = 32 > 16 (maximum alignment on linux x86_64) > 8 (maximum alignment on mac arm64). Bug: chromium:388068052 Change-Id: If08b69f7a5ff7b716a66c8703e31eb5d4de14431 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/373800 Commit-Queue: Victor Vianna <victorvianna@google.com> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Auto-Submit: Victor Vianna <victorvianna@google.com> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43842}
This commit is contained in:
parent
c262375415
commit
a6f35491d6
@ -30,8 +30,9 @@ enum : size_t { kInlineStorageWords = 4 };
|
|||||||
union VoidUnion {
|
union VoidUnion {
|
||||||
void* void_ptr;
|
void* void_ptr;
|
||||||
FunVoid* fun_ptr;
|
FunVoid* fun_ptr;
|
||||||
typename std::aligned_storage<kInlineStorageWords * sizeof(uintptr_t)>::type
|
// std::max_align_t satisfies alignment requirements for every type.
|
||||||
inline_storage;
|
alignas(std::max_align_t) char inline_storage[kInlineStorageWords *
|
||||||
|
sizeof(uintptr_t)];
|
||||||
};
|
};
|
||||||
|
|
||||||
// Returns the number of elements of the `inline_storage` array required to
|
// Returns the number of elements of the `inline_storage` array required to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user