* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / constexpr-cast.C
blobe0c7ed33ac7159304fea4b6f493cf4c344e2b7f0
1 // Test to verify that evaluating reinterpret_cast is diagnosed in
2 // constant expressions.
3 // { dg-do compile { target c++11 } }
5 int i;
7 // The following was accepted due to bug 49171.
8 constexpr void *q = reinterpret_cast<void*>(&i);    // { dg-error "not a constant expression" }
10 constexpr void *r0 = reinterpret_cast<void*>(1);    // { dg-error "not a constant expression|reinterpret_cast from integer to pointer" }
11 constexpr void *r1 = reinterpret_cast<void*>(sizeof 'x');  // { dg-error ".reinterpret_cast<void\\*>\\(1\[ul\]\*\\). is not a constant expression" }
13 template <class T>
14 constexpr bool f ()
16 #if __cplusplus > 201103L
17   T *p = reinterpret_cast<T*>(sizeof (T));
18   return p;
19 #else
20   return *reinterpret_cast<T*>(sizeof (T));
21 #endif
24 constexpr bool b = f<int>();   // { dg-error "not a constant expression|in .constexpr. expansion of " }