Debian Codegraph @

gcc/testsuite/g++.dg/cpp26/constexpr-voidptr2.C

raw
1 // PR c++/110344
2 // { dg-do compile { target c++26 } }
3
4 struct A { int i; };
5 struct B { A a; };
6
7 constexpr int f()
8 {
9 B b { 42 };
10 void *p = &b;
11 A* ap = static_cast<A*>(p);
12 return ap->i;
13 }
14
15 static_assert (f() == 42);