Skip to content

Commit 61a5556

Browse files
committed
use construct_at for placement new gcc workaround
1 parent d24a714 commit 61a5556

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

libcxx/include/__algorithm/stable_sort.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <__cstddef/ptrdiff_t.h>
1919
#include <__debug_utils/strict_weak_ordering_check.h>
2020
#include <__iterator/iterator_traits.h>
21+
#include <__memory/construct_at.h>
2122
#include <__memory/destruct_n.h>
2223
#include <__memory/unique_ptr.h>
2324
#include <__memory/unique_temporary_buffer.h>
@@ -37,9 +38,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
3738

3839
// Workaround for "constexpr placement new" bug in gcc (fixed in 14.2).
3940
// See https://github.com/llvm/llvm-project/pull/110320#discussion_r1788557715.
40-
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 <= 140100)
41-
# define _LIBCPP_MOVING_PLACEMENT_NEW(__ptr, __type, __move_func, __iter) \
42-
[__ptr, &__iter] { ::new ((void*)__ptr) __type(__move_func(__iter)); }()
41+
#if (_LIBCPP_STD_VER >= 20) || \
42+
(!defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 <= 140100))
43+
# define _LIBCPP_MOVING_PLACEMENT_NEW(__ptr, __type, __move_func, __iter) std::construct_at(__ptr, __move_func(__iter))
4344
#else
4445
# define _LIBCPP_MOVING_PLACEMENT_NEW(__ptr, __type, __move_func, __iter) \
4546
::new ((void*)__ptr) __type(__move_func(__iter))

0 commit comments

Comments
 (0)