1 // Test to verify that evaluating reinterpret_cast is diagnosed in
2 // constant expressions.
3 // { dg-do compile { target c++11 } }
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" }
16 #if __cplusplus > 201103L
17 T *p = reinterpret_cast<T*>(sizeof (T));
20 return *reinterpret_cast<T*>(sizeof (T));
24 constexpr bool b = f<int>(); // { dg-error "not a constant expression|in .constexpr. expansion of " }