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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |jsm28 at gcc dot gnu.org,
                   |                            |rsandifo at gcc dot gnu.org

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And it is actually far worse than just the ICEs.
Consider:
struct A { int a; };
struct B { int b; struct A c[]; };
struct C { int d; struct B e[]; };
struct D { int f; int g[]; };
struct E { int h; struct D i[]; };
struct B j = { .c = { { 1 } } };
struct C k = { .e = { j, j } };
struct D l = { .g = { 1 } };
struct E m = { .i = { l, l } };
in C++, or say:
struct A { int a; };
struct B { int b; struct A c[]; };
struct D { int f; int g[]; };
struct B j = { .c = { { 1 } } };
struct D l = { .g = { 1 } };
struct B k;
struct D m;

int
main ()
{
  k = j;
  m = l;
}
in C/C++.  These compile fine, but at runtime copy not just the sizeof (int)
bytes that
the destination has for the type, but actually 8 bytes.
So, e.g. in the latter testcase, k and m are 4 byte, while j and l are 8 byte,
and at least for C since I think r0-73097-g1f0f7cebf9eccfa3c9ba the assignments
copy 8 bytes rather than 4 bytes they copied previously.  In C++ that is since
my
r12-3526-g818c505188ff5cd8eb048eb change.  So, I think we want to figure out
what to do about those runtime copies first (whether they only copy the type's
size or what else),
and once that is decided, handle the constant cases the same, since anything
else would be just weird.  But in that case #c7 would be valid and would just
copy into the initializer everything but the flexible array member from the
const vars.  Or do we want to treat that way only vars in the non-trailing
positions (where putting there their initializer by hand would result in the
above mentioned error) and for the use at the trailing position act as if the
complete initializer appeared there (i.e. initialize the flexible array member
also))?

Reply via email to