re PR c++/80691 (Narrowing conversion in {} allowed in a SFINAE context)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 8 May 2018 08:55:30 +0000 (08:55 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 8 May 2018 08:55:30 +0000 (08:55 +0000)
2018-05-08  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/80691
* g++.dg/cpp0x/narrowing1.C: New.

From-SVN: r260027

gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/narrowing1.C [new file with mode: 0644]

index 795af52dcdc53bbb93a2202dd2d0dbd68bf3a3f5..000dc689f5326812c879a06b89c6e9bb933e2a56 100644 (file)
@@ -1,3 +1,8 @@
+2018-05-08  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/80691
+       * g++.dg/cpp0x/narrowing1.C: New.
+
 2018-05-08  Richard Biener  <rguenther@suse.de>
 
        PR middle-end/85588
diff --git a/gcc/testsuite/g++.dg/cpp0x/narrowing1.C b/gcc/testsuite/g++.dg/cpp0x/narrowing1.C
new file mode 100644 (file)
index 0000000..ba4bb4e
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/80691
+// { dg-do compile { target c++11 } }
+
+struct true_type { static constexpr bool value = true; };
+struct false_type { static constexpr bool value = false; };
+template<typename...> using void_t = void;
+template<typename T> T&& declval();
+
+template<typename T, typename U, typename = void>
+struct is_nonnarrowing_conversion : false_type {};
+
+template<typename T, typename U>
+struct is_nonnarrowing_conversion<T, U,
+    void_t<decltype(T{ declval<U>() })>> : true_type {};
+
+template<typename T>
+class wrapper
+{
+public:
+    wrapper(T) {}
+};
+
+static_assert(!is_nonnarrowing_conversion<int, float>::value, "");
+static_assert(!is_nonnarrowing_conversion<wrapper<int>, float>::value, "");