From ac1a984a5f45df2273bb58445378bc8ecff18564 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Fri, 19 Dec 2014 00:02:05 +0000 Subject: [PATCH] re PR c++/63723 (Narrowing conversion allowed in braced init list in SFINAE context) 2014-12-18 Paolo Carlini PR c++/63723 * g++.dg/cpp0x/sfinae54.C: New. From-SVN: r218880 --- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/cpp0x/sfinae54.C | 41 +++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/sfinae54.C diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 878a82e508c..87453b57fab 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-18 Paolo Carlini + + PR c++/63723 + * g++.dg/cpp0x/sfinae54.C: New. + 2014-12-18 Paolo Carlini PR c++/59204 diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae54.C b/gcc/testsuite/g++.dg/cpp0x/sfinae54.C new file mode 100644 index 00000000000..f681fa7fa3e --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/sfinae54.C @@ -0,0 +1,41 @@ +// PR c++/63723 +// { dg-do compile { target c++11 } } + +template Tp declval(); + +template +struct integral_constant +{ + static constexpr Tp value = v; + typedef Tp value_type; + typedef integral_constant type; + constexpr operator value_type() const { return value; } +}; + +typedef integral_constant true_type; +typedef integral_constant false_type; + +template +class is_list_convertible_helper +{ + template + static void requires_conversion(To2 t); + + template ({declval()}))> + static true_type helper(int); + + template + static false_type helper(...); + +public: + using type = decltype(helper(0)); +}; + +template +class is_list_convertible + : public is_list_convertible_helper::type +{ }; + +static_assert(!is_list_convertible::value, + "double -> int is narrowing!"); -- 2.30.2