Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 // PR c++/56728 | |
2 // { dg-require-effective-target c++11 } | |
3 | |
4 class B { | |
5 public: | |
6 static B instance; | |
7 class Inner | |
8 { | |
9 public: | |
10 class Wuzi | |
11 { | |
12 unsigned int m; | |
13 } m_Class[3]; | |
14 unsigned m_Int[4]; | |
15 }; | |
16 | |
17 constexpr static Inner & getInner() | |
18 /* I am surprised this is considered a constexpr */ | |
19 { return *((Inner *)4); } // { dg-error "reinterpret_cast" } | |
20 }; | |
21 | |
22 B B::instance; | |
23 | |
24 class A | |
25 { | |
26 public: | |
27 constexpr A(B &bridge, B::Inner &bridge2, unsigned char index) | |
28 : m_Bridge(bridge), m_Wuz(bridge2.m_Class[index]) | |
29 {} | |
30 | |
31 B &m_Bridge; | |
32 B::Inner::Wuzi &m_Wuz; | |
33 }; | |
34 A works{B::instance, B::getInner(), 3}; | |
35 A crashnkill[1]{{B::instance, B::getInner(), 3}}; |