| 1 |
// PR c++/57599 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
struct A { }; |
| 5 |
struct B : public A { }; |
| 6 |
|
| 7 |
template<class, class> |
| 8 |
struct is_same { static constexpr bool value = false; }; |
| 9 |
|
| 10 |
template<class T> |
| 11 |
struct is_same<T, T> { static constexpr bool value = true; }; |
| 12 |
|
| 13 |
template<class T> |
| 14 |
T val(); |
| 15 |
|
| 16 |
static_assert(is_same<decltype(dynamic_cast<A*>(val<B*>())), |
| 17 |
A*>::value, "Ouch"); |
| 18 |
static_assert(is_same<decltype(dynamic_cast<A&>(val<B&>())), |
| 19 |
A&>::value, "Ouch"); |
| 20 |
static_assert(is_same<decltype(dynamic_cast<const A*>(val<B*>())), |
| 21 |
const A*>::value, "Ouch"); |
| 22 |
static_assert(is_same<decltype(dynamic_cast<const A&>(val<B&>())), |
| 23 |
const A&>::value, "Ouch"); |
| 24 |
static_assert(is_same<decltype(dynamic_cast<volatile A*>(val<B*>())), |
| 25 |
volatile A*>::value, "Ouch"); |
| 26 |
static_assert(is_same<decltype(dynamic_cast<volatile A&>(val<B&>())), |
| 27 |
volatile A&>::value, "Ouch"); |
| 28 |
static_assert(is_same<decltype(dynamic_cast<const volatile A*>(val<B*>())), |
| 29 |
const volatile A*>::value, "Ouch"); |
| 30 |
static_assert(is_same<decltype(dynamic_cast<const volatile A&>(val<B&>())), |
| 31 |
const volatile A&>::value, "Ouch"); |