Patchwork [C++] PR 57599

login
register
mail settings
Submitter Paolo Carlini
Date June 13, 2013, 9:17 a.m.
Message ID <51B98E18.2030908@oracle.com>
Download mbox | patch
Permalink /patch/251022/
State New
Headers show

Comments

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

Thanks,
Paolo.

////////////////7

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");