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

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

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
But this isn't a designed array initializer, it is a normal initializer with
side-effects in it.
And presumably the C++ FE lowered that into
{[3]=5, [0]=5, [7]=3, [1]=3}
which is considered invalid by the middle-end, since it isn't sorted by
increasing index.
With
static int array[10] = { array[3]=5, array[7]=3, array[7]=8, array[7] = 9 };
it is even worse, we get
{[3]=5, [0]=5, [7]=9, [1]=3, [2]=8, [3]=9}
so [3] is written twice.  Not sure if this isn't undefined behavior (I hope it
is), but still we shouldn't ICE on it, best would be not to turn the stores
into CONSTRUCTOR elements, but just handle the side-effects at runtime.

Reply via email to