// PR c++/94074 - wrong modifying const object error for COMPONENT_REF. // { dg-do compile { target c++14 } } typedef decltype (sizeof (0)) size_t; template struct array { constexpr const E &operator[](size_t n) const noexcept { return elems[n]; } E elems[N]; }; template struct array2 { array a; }; template struct S { using U = array2; const U m; // { dg-message "originally declared" } constexpr S(int) : m{} { const_cast(m.a[0]) = 42; // { dg-error "modifying a const object" } } }; constexpr S p = { 10 };