Skip to content

Commit f7885f0

Browse files
committed
[libc++] Fix constant initialization of unique_ptr in C++17 and prior
1 parent 50320ec commit f7885f0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

libcxx/include/__memory/compressed_pair.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ template <class _ToPad>
5656
class __compressed_pair_padding {
5757
char __padding_[((is_empty<_ToPad>::value && !__libcpp_is_final<_ToPad>::value) || is_reference<_ToPad>::value)
5858
? 0
59-
: sizeof(_ToPad) - __datasizeof_v<_ToPad>];
59+
: sizeof(_ToPad) - __datasizeof_v<_ToPad>] = {};
6060
};
6161

6262
# define _LIBCPP_COMPRESSED_PAIR(T1, Initializer1, T2, Initializer2) \

libcxx/test/support/test_macros.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,11 @@
221221
#endif
222222

223223
#if TEST_STD_VER > 17
224-
#define TEST_CONSTINIT constinit
224+
# define TEST_CONSTINIT constinit
225+
#elif __has_cpp_attribute(clang::require_constant_initialization)
226+
# define TEST_CONSTINIT [[clang::require_constant_initialization]]
225227
#else
226-
#define TEST_CONSTINIT
228+
# define TEST_CONSTINIT
227229
#endif
228230

229231
#if TEST_STD_VER < 11

0 commit comments

Comments
 (0)