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

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
And this should compile fine but doesn't since r269078:

struct A {
  int i;
};
struct B {
  A a{};
  constexpr B() : a() {}
  constexpr B(const B &rhs) : a(rhs.a) {}
};
struct C {
  B arr[1];
};

constexpr C
fn ()
{
  C c{};
  return c;
}

constexpr C c = fn();

$ ./cc1plus -quiet 101371.C
101371.C:20:20:   in ‘constexpr’ expansion of ‘fn()()’
101371.C:17:10:   in ‘constexpr’ expansion of ‘C(c)’
101371.C:20:20:   in ‘constexpr’ expansion of ‘B(<anonymous>.C::arr[0])’
101371.C:20:20:   in ‘constexpr’ expansion of ‘B()’
101371.C:20:20: error: accessing value of ‘<anonymous>.B::a’ through a ‘B’
glvalue in a constant expression
   20 | constexpr C c = fn();
      |                    ^

Reply via email to