[Bug c++/91548] [10 Regression] Regression in constexpr evaluation of std::array

mpolacek at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Oct 22 21:53:00 GMT 2019


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91548

--- Comment #7 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Thanks.

Reduced (no templates, no lambda):

constexpr int& impl(const int (&array)[10], int index) {
  return const_cast<int&>(array[index]);
}

struct A {
  constexpr int& operator[](int i) { return impl(elems, i); }
  int elems[10];
};

constexpr bool
f()
{
  A arr = {};
  arr[2] = true;
  return false;
}

constexpr bool b = f();


More information about the Gcc-bugs mailing list