blob: 69db98bc7727a5b282638224be609131c737474b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// PR c++/56728
// { dg-require-effective-target c++11 }
class B {
public:
static B instance;
class Inner
{
public:
class Wuzi
{
unsigned int m;
} m_Class[3];
unsigned m_Int[4];
};
constexpr static Inner & getInner()
{
/* I am surprised this is considered a constexpr */
return *((Inner *)4);
} // { dg-error "reinterpret_cast" }
};
B B::instance;
class A
{
public:
constexpr A(B &bridge, B::Inner &bridge2, unsigned char index)
: m_Bridge(bridge), m_Wuz(bridge2.m_Class[index])
{}
B &m_Bridge;
B::Inner::Wuzi &m_Wuz;
};
A works{B::instance, B::getInner(), 3};
A crashnkill[1]{{B::instance, B::getInner(), 3}};
|