diff mbox

[C++] PR 57599

Message ID 51B98E18.2030908@oracle.com
State New
Headers show

Commit Message

Paolo Carlini June 13, 2013, 9:17 a.m. UTC
... in any case, I propose to also add to /cpp0x this testcase suggested 
by Daniel.

Thanks,
Paolo.

////////////////7
diff mbox

Patch

Index: g++.dg/cpp0x/dyncast1.C
===================================================================
--- g++.dg/cpp0x/dyncast1.C	(revision 0)
+++ g++.dg/cpp0x/dyncast1.C	(working copy)
@@ -0,0 +1,27 @@ 
+// PR c++/57599
+// { dg-do compile { target c++11 } }
+
+struct A { };
+struct B : public A { };
+
+template<class, class>
+struct is_same { static constexpr bool value = false; };
+
+template<class T>
+struct is_same<T, T> { static constexpr bool value = true; };
+
+template<class T>
+T val();
+
+static_assert(is_same<decltype(dynamic_cast<const A*>(val<B*>())),
+	      const A*>::value, "Ouch");
+static_assert(is_same<decltype(dynamic_cast<const A&>(val<B&>())),
+	      const A&>::value, "Ouch");
+static_assert(is_same<decltype(dynamic_cast<volatile A*>(val<B*>())),
+	      volatile A*>::value, "Ouch");
+static_assert(is_same<decltype(dynamic_cast<volatile A&>(val<B&>())),
+	      volatile A&>::value, "Ouch");
+static_assert(is_same<decltype(dynamic_cast<const volatile A*>(val<B*>())),
+	      const volatile A*>::value, "Ouch");
+static_assert(is_same<decltype(dynamic_cast<const volatile A&>(val<B&>())),
+	      const volatile A&>::value, "Ouch");