Already fixed by r10-8124-gceae6a13366d9646e172fc943fe8e221b70f0920.

Tested x86_64-pc-linux-gnu, applying to trunk.

        PR c++/95143
        * g++.dg/cpp0x/sfinae66.C: New test.
---
 gcc/testsuite/g++.dg/cpp0x/sfinae66.C | 32 +++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/sfinae66.C

diff --git a/gcc/testsuite/g++.dg/cpp0x/sfinae66.C 
b/gcc/testsuite/g++.dg/cpp0x/sfinae66.C
new file mode 100644
index 00000000000..49067cd35d0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/sfinae66.C
@@ -0,0 +1,32 @@
+// PR c++/95143
+// { dg-do compile { target c++11 } }
+
+struct false_type {
+  static constexpr bool value = false;
+};
+
+struct true_type{
+  static constexpr bool value = true;
+};
+
+template<class T>
+T&& declval() noexcept;
+
+template<typename T, typename U, typename = U>
+struct is_static_castable : false_type
+{};
+template<typename T, typename U>
+struct is_static_castable<T, U, decltype(static_cast<U>(declval<T>()))> : 
true_type
+{};
+
+class Base { };
+struct A { };
+class B: public Base { };
+
+int main()
+{
+  constexpr auto canCast = is_static_castable<A, B>::value;
+  static_assert(!canCast, "");
+  constexpr auto canCast2 = is_static_castable<A, A>::value;
+  static_assert(canCast2, "");
+}

base-commit: 24f68831d25bad739a6fe167a58b5b4c0c3cbf9a
-- 
Marek Polacek • Red Hat, Inc. • 300 A St, Boston, MA

Reply via email to