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

--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Slightly further reduced:

struct A {
  int a[256];
  constexpr int &operator[] (int n) noexcept { return a[n]; }
  constexpr const int &operator[] (int n) const noexcept { return a[n]; }
};
struct B {};
template <typename T>
struct C {
  constexpr T &foo (const char x) noexcept { c = T::d[x]; return static_cast<T
&>(*this); }
  int c;
};
struct D : public C<D>, public B
{
  constexpr D () noexcept = default;
  static constexpr char e[9] { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I' };
  static constexpr A d = [] () constexpr {
    A f {};
    for (int i = 0; i < 9; ++i)
      f[e[i]] = 1;
    return f;
  } ();
};
constexpr auto g = D{}.foo ('E');

Reply via email to