comparison gcc/testsuite/g++.dg/cpp1y/constexpr-tracking-const20.C @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
comparison
equal deleted inserted replaced
18:1830386684a0 19:2b5abeee2509
1 // PR c++/94074 - wrong modifying const object error for COMPONENT_REF.
2 // { dg-do compile { target c++14 } }
3
4 typedef decltype (sizeof (0)) size_t;
5
6 template <typename E, size_t N>
7 struct array
8 {
9 constexpr const E &operator[](size_t n) const noexcept { return elems[n]; }
10 E elems[N];
11 };
12
13 template <typename E, size_t N>
14 struct array2 {
15 array<E, N> a;
16 };
17
18 template <typename T>
19 struct S {
20 using U = array2<T, 4>;
21 U m;
22 constexpr S(int) : m{}
23 {
24 const_cast<int &>(const_cast<const U &>(m).a[0]) = 42;
25 }
26 };
27
28 constexpr S<int> p = { 10 };