Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/cpp1y/pr78551.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
// { dg-do compile { target c++14 } } // PR c++/78551 ICE in constexpr evaluation overwriting array // intialized by string constant. constexpr char Foo (char x, int ix) { char d[4] = "012"; d[0] = x; return d[ix]; } static const char a = Foo ('a', 1); static const char b = Foo ('a', 0); static_assert (a == '1', ""); static_assert (b == 'a', ""); struct A { union { long s; char d[4]; }; constexpr A (char x) : d("012") { d[0] = x; } }; static constexpr A c{'a'}; static_assert (c.d[0] == 'a', ""); static_assert (c.d[1] == '1', "");