Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp2a/constexpr-dynamic18.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 // PR c++/93414 - poor diagnostic for dynamic_cast in constexpr context. | |
2 // { dg-do compile { target c++2a } } | |
3 // Here 'b' doesn't point/refer to a public base of Derived. | |
4 | |
5 struct Base { | |
6 constexpr virtual ~Base(){} | |
7 }; | |
8 | |
9 struct Derived: Base { | |
10 constexpr ~Derived(){} | |
11 }; | |
12 | |
13 constexpr const Derived& cast(const Base& b) { | |
14 return dynamic_cast<const Derived&>(b); // { dg-error "reference .dynamic_cast. failed" } | |
15 // { dg-message "dynamic type .const Base. of its operand does not have a base class of type .Derived." "" { target *-*-* } .-1 } | |
16 } | |
17 | |
18 auto test() { | |
19 static constexpr Base b; | |
20 constexpr auto res = cast(b); | |
21 return res; | |
22 } |