1 // PR c++/94074 - wrong modifying const object error for COMPONENT_REF.
2 // { dg-do compile { target c++14 } }
4 typedef decltype (sizeof (0)) size_t;
6 template <typename E, size_t N>
9 constexpr const E &operator[](size_t n) const noexcept { return elems[n]; }
10 const E elems[N]; // { dg-message "originally declared" }
15 using U = array<T, 4>;
17 constexpr S(int) : m{}
19 const_cast<int &>(const_cast<const U &>(m)[0]) = 42; // { dg-error "modifying a const object" }
23 constexpr S<int> p = { 10 };