fortran/openmp.cc: Fix var init and locus use to avoid uninit values [PR fortran...
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-union7.C
blob6fc41f973543a72624e8541123cc0b3b823ae8ca
1 // { dg-do compile { target c++14 } }
3 // this type is not value-initialisable
4 struct S { const int a; int b; };
6 union U1 { int k; S s; };
7 constexpr int test1() {
8   U1 u {};
9   return u.s.b;  // { dg-error "accessing .U1::s. member instead of initialized .U1::k. member" }
11 constexpr int x = test1();
13 union U2 { int :0; static int s; void foo(); int k; };
14 constexpr int test2() {
15   U2 u {};  // should skip zero-width bitfields, static members, and functions
16   return u.k;
18 static_assert(test2() == 0, "");