Skip to content

Commit b8e3985

Browse files
ldionneBogdan Graur
authored andcommitted
Add release note, simplify tests.
1 parent d4ae572 commit b8e3985

File tree

7 files changed

+15
-19
lines changed

7 files changed

+15
-19
lines changed

libcxx/docs/ReleaseNotes/18.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ Deprecations and Removals
8181
- The non-conforming constructor ``std::future_error(std::error_code)`` has been removed. Please use the
8282
``std::future_error(std::future_errc)`` constructor provided in C++17 instead.
8383

84+
- `P1957 <https://wg21.link/P1957>` has been implemented in Clang and libc++ removed a code path that led to
85+
narrowing conversions in ``std::variant`` behaving in a non-standard way. This may change how some uses of
86+
``std::variant``'s constructor behave in user code. The ``_LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT``
87+
macro is provided to restore the previous behavior, and it will be supported in the LLVM 18 release only.
88+
In LLVM 19 and beyond, ``_LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT`` will not be honored anymore.
89+
8490
Upcoming Deprecations and Removals
8591
----------------------------------
8692

libcxx/include/variant

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ struct __overload {
12521252
auto operator()(_Tp, _Up&&) const -> __check_for_narrowing<_Tp, _Up>;
12531253
};
12541254

1255+
// TODO(LLVM-19): Remove all occurrences of this macro.
12551256
#ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
12561257
template <class _Tp, size_t>
12571258
struct __overload_bool {

libcxx/test/std/utilities/variant/variant.variant/variant.assign/T.pass.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ void test_T_assignment_sfinae() {
146146
};
147147
static_assert(!std::is_assignable<V, X>::value,
148148
"no boolean conversion in operator=");
149-
#ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
150-
static_assert(!std::is_assignable<V, std::false_type>::value,
151-
"no converted to bool in operator=");
152-
#else
149+
#ifndef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
153150
static_assert(std::is_assignable<V, std::false_type>::value,
154151
"converted to bool in operator=");
155152
#endif

libcxx/test/std/utilities/variant/variant.variant/variant.assign/conv.pass.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ int main(int, char**)
3333

3434
static_assert(!std::is_assignable<std::variant<int, bool>, decltype("meow")>::value, "");
3535
static_assert(!std::is_assignable<std::variant<int, const bool>, decltype("meow")>::value, "");
36-
#ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
37-
static_assert(!std::is_assignable<std::variant<int, const volatile bool>, decltype("meow")>::value, "");
38-
static_assert(!std::is_assignable<std::variant<bool>, std::true_type>::value, "");
39-
#else
36+
37+
#ifndef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
4038
static_assert(std::is_assignable<std::variant<bool>, std::true_type>::value, "");
4139
#endif
42-
4340
static_assert(!std::is_assignable<std::variant<bool>, std::unique_ptr<char> >::value, "");
4441
static_assert(!std::is_assignable<std::variant<bool>, decltype(nullptr)>::value, "");
4542

libcxx/test/std/utilities/variant/variant.variant/variant.ctor/T.pass.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ void test_T_ctor_sfinae() {
8080
};
8181
static_assert(!std::is_constructible<V, X>::value,
8282
"no boolean conversion in constructor");
83-
#ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
84-
static_assert(!std::is_constructible<V, std::false_type>::value,
85-
"no converted to bool in constructor");
86-
#else
83+
#ifndef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
8784
static_assert(std::is_constructible<V, std::false_type>::value,
8885
"converted to bool in constructor");
8986
#endif

libcxx/test/std/utilities/variant/variant.variant/variant.ctor/conv.pass.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,10 @@ int main(int, char**)
3232

3333
static_assert(!std::is_constructible<std::variant<int, bool>, decltype("meow")>::value, "");
3434
static_assert(!std::is_constructible<std::variant<int, const bool>, decltype("meow")>::value, "");
35-
#ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
36-
static_assert(!std::is_constructible<std::variant<int, const volatile bool>, decltype("meow")>::value, "");
37-
static_assert(!std::is_constructible<std::variant<bool>, std::true_type>::value, "");
38-
#else
35+
36+
#ifndef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
3937
static_assert(std::is_constructible<std::variant<bool>, std::true_type>::value, "");
4038
#endif
41-
4239
static_assert(!std::is_constructible<std::variant<bool>, std::unique_ptr<char> >::value, "");
4340
static_assert(!std::is_constructible<std::variant<bool>, decltype(nullptr)>::value, "");
4441

libcxx/test/support/variant_test_helpers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323

2424
// FIXME: Currently the variant<T&> tests are disabled using this macro.
2525
#define TEST_VARIANT_HAS_NO_REFERENCES
26+
27+
// TODO(LLVM-19): Remove TEST_VARIANT_ALLOWS_NARROWING_CONVERSIONS
2628
#ifdef _LIBCPP_ENABLE_NARROWING_CONVERSIONS_IN_VARIANT
2729
# define TEST_VARIANT_ALLOWS_NARROWING_CONVERSIONS
2830
#endif
29-
3031
#ifdef TEST_VARIANT_ALLOWS_NARROWING_CONVERSIONS
3132
constexpr bool VariantAllowsNarrowingConversions = true;
3233
#else

0 commit comments

Comments
 (0)