diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C')
-rw-r--r-- | gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C new file mode 100644 index 0000000..69db98b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/constexpr-reinterpret1.C @@ -0,0 +1,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}}; |