1 // { dg-do compile { target c++14 } }
2 
3 // PR c++/78551 ICE in constexpr evaluation overwriting array
4 // intialized by string constant.
5 
Foo(char x,int ix)6 constexpr char Foo (char x, int ix)
7 {
8   char d[4] = "012";
9   d[0] = x;
10   return d[ix];
11 }
12 
13 static const char a = Foo ('a', 1);
14 static const char b = Foo ('a', 0);
15 
16 static_assert (a == '1', "");
17 static_assert (b == 'a', "");
18 
19 struct A {
20   union {
21     long s;
22     char d[4];
23   };
AA24   constexpr A (char x)
25     : d("012")
26   { d[0] = x; }
27 };
28 
29 static constexpr A c{'a'};
30 
31 static_assert (c.d[0] == 'a', "");
32 static_assert (c.d[1] == '1', "");
33