1 // PR c++/89481
2 // { dg-do compile { target c++14 } }
3 
4 constexpr int
foo()5 foo ()
6 {
7   union U { long long a; int b[2]; } u { 5LL };
8   u.b[1] = 4;		// { dg-error "change of the active member of a union from" "" { target c++17_down } }
9   return u.b[0];
10 }
11 
12 constexpr int
bar()13 bar ()
14 {
15   union U { long long a; int b[2]; } u { 5LL };
16   u.b[1] = 4;		// { dg-error "change of the active member of a union from" "" { target c++17_down } }
17   return u.b[1];
18 }
19 
20 static_assert (foo () == 0, "");	// { dg-error "non-constant condition for static assertion" }
21 					// { dg-message "in 'constexpr' expansion of" "" { target *-*-* } .-1 }
22 					// { dg-error "accessing uninitialized array element" "" { target c++2a } .-2 }
23 static_assert (bar () == 4, "");	// { dg-error "non-constant condition for static assertion" "" { target c++17_down } }
24 					// { dg-message "in 'constexpr' expansion of" "" { target c++17_down } .-1 }
25