diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 3000928b6..2056568fc 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1661,9 +1661,9 @@ struct _Invoker_ret<_Unforced, false> { // selected for _Rx being _Unforced // TYPE TRAITS FOR invoke() #pragma warning(push) -#pragma warning(disable : 4242) // 'identifier': conversion from '_From' to '_To', possible loss of data (/Wall) -#pragma warning(disable : 4244) // 'argument': conversion from '_From' to '_To', possible loss of data -#pragma warning(disable : 4365) // 'argument': conversion from '_From' to '_To', signed/unsigned mismatch (/Wall) +#pragma warning(disable : 4242) // '%s': conversion from '%s' to '%s', possible loss of data (/Wall) +#pragma warning(disable : 4244) // '%s': conversion from '%s' to '%s', possible loss of data (Yes, duplicated message.) +#pragma warning(disable : 4365) // '%s': conversion from '%s' to '%s', signed/unsigned mismatch (/Wall) #pragma warning(disable : 5215) // '%s' a function parameter with a volatile qualified type is deprecated in C++20 #ifdef __clang__ diff --git a/stl/inc/variant b/stl/inc/variant index a9913e0fc..dd781e530 100644 --- a/stl/inc/variant +++ b/stl/inc/variant @@ -962,6 +962,9 @@ using _Variant_destroy_layer = conditional_t @@ -969,11 +972,6 @@ struct _Variant_init_single_overload { using _FTy = _Meta_list, _Ty> (*)(_Ty); operator _FTy(); }; -#ifdef __clang__ -#pragma clang diagnostic pop -#else // ^^^ Clang / not Clang vvv -#pragma warning(pop) -#endif // __clang__ template struct _Variant_init_overload_set_; @@ -1001,11 +999,16 @@ using _Variant_init_type = _Meta_front<_Meta_pop_front // extract the index from _Variant_init_helper using _Variant_init_index = _Meta_front::type>; +#ifdef __clang__ +#pragma clang diagnostic pop +#else // ^^^ Clang / not Clang vvv +#pragma warning(pop) +#endif // __clang__ template -struct _Is_in_place_index_specialization : false_type {}; +inline constexpr bool _Is_in_place_index_specialization = false; template -struct _Is_in_place_index_specialization> : true_type {}; +inline constexpr bool _Is_in_place_index_specialization> = true; template class variant : private _SMF_control<_Variant_destroy_layer<_Types...>, _Types...> { // discriminated union @@ -1026,7 +1029,7 @@ public: enable_if_t, variant> // && !_Is_specialization_v<_Remove_cvref_t<_Ty>, in_place_type_t> // - && !_Is_in_place_index_specialization<_Remove_cvref_t<_Ty>>::value // + && !_Is_in_place_index_specialization<_Remove_cvref_t<_Ty>> // && is_constructible_v<_Variant_init_type<_Ty, _Types...>, _Ty>, // int> = 0> constexpr variant(_Ty&& _Obj) noexcept(is_nothrow_constructible_v<_Variant_init_type<_Ty, _Types...>, _Ty>) diff --git a/tests/std/tests/P0088R3_variant/test.cpp b/tests/std/tests/P0088R3_variant/test.cpp index 669e138b3..2cf2dd521 100644 --- a/tests/std/tests/P0088R3_variant/test.cpp +++ b/tests/std/tests/P0088R3_variant/test.cpp @@ -7067,6 +7067,20 @@ namespace msvc { static_assert(!std::is_copy_constructible_v>); } } // namespace vso508126 + + namespace DevCom1031281 { + // Compilers may warn when initializing a variant from a "weird" argument, e.g., std::variant{some_int} + // is potentially narrowing. Compilers should not, however, emit such diagnostics from the metaprogramming that + // determines which alternative a variant initialization would activate. We don't want to emit warnings when + // determining implicit conversion sequences early in overload resolution. + + void Overload(int) {} + void Overload(std::variant) {} + + void run_test() { + Overload(42); + } + } // namespace DevCom1031281 } // namespace msvc int main() { @@ -7128,4 +7142,5 @@ int main() { msvc::vso468746::run_test(); msvc::vso508126::run_test(); msvc::vso492097::run_test(); + msvc::DevCom1031281::run_test(); } diff --git a/tests/std/tests/VSO_0180469_fill_family/test.cpp b/tests/std/tests/VSO_0180469_fill_family/test.cpp index bf1602f1e..164e03180 100644 --- a/tests/std/tests/VSO_0180469_fill_family/test.cpp +++ b/tests/std/tests/VSO_0180469_fill_family/test.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #pragma warning(disable : 4242) // conversion from 'X' to 'Y', possible loss of data -#pragma warning(disable : 4244) // conversion from 'X' to 'Y', possible loss of data +#pragma warning(disable : 4244) // conversion from 'X' to 'Y', possible loss of data (Yes, duplicated message.) // Note that this test *should* trigger 4242 and 4244 inside STL headers, because it // calls std::fill and std::uninitialized_fill with (small type*, small type*, big type) #pragma warning(disable : 4365) // conversion from 'X' to 'Y', signed/unsigned mismatch diff --git a/tests/tr1/tests/functional1/test.cpp b/tests/tr1/tests/functional1/test.cpp index abc69c0cd..c2038327d 100644 --- a/tests/tr1/tests/functional1/test.cpp +++ b/tests/tr1/tests/functional1/test.cpp @@ -10,7 +10,7 @@ #define _SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING #pragma warning(disable : 4242) // conversion from 'X' to 'Y', possible loss of data -#pragma warning(disable : 4244) // conversion from 'X' to 'Y', possible loss of data +#pragma warning(disable : 4244) // conversion from 'X' to 'Y', possible loss of data (Yes, duplicated message.) #include "tdefs.h" #include