projects
/
gcc.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
c++: Implement LWG3396 Clarify point of reference for source_location::current()...
[gcc.git]
/
gcc
/
testsuite
/
g++.dg
/
cpp2a
/
constexpr-dynamic3.C
1
// PR c++/88337 - Implement P1327R1: Allow dynamic_cast/typeid in constexpr.
2
// { dg-do compile { target c++20 } }
3
4
// Sidecast.
5
6
struct A {
7
virtual void afn () {}
8
};
9
10
struct B {
11
virtual void bfn () {}
12
};
13
14
struct D : A, B { };
15
16
constexpr bool
17
fn ()
18
{
19
bool ok = true;
20
D d;
21
A *a = &d;
22
if (B *bp = dynamic_cast<B*>(a))
23
/*OK*/;
24
else
25
ok = false;
26
27
A &ar = d;
28
B &br = dynamic_cast<B&>(ar);
29
30
return ok;
31
}
32
33
static_assert(fn ());