Re: [PR c++/78572] handle array self references in intializers

2016-12-21 Thread Jakub Jelinek
On Wed, Dec 21, 2016 at 12:29:37PM -0500, Aldy Hernandez wrote: > > > int array[10] = { array[3]=5, 0x111, 0x222, 0x333 }; > > > > > > (gdb) x/4x &array > > > 0x601040 : 0x0005 0x0111 0x0222 > > > 0x0005 > > > > > > That is, the array[3]=5 overwrites the last 0x333

Re: [PR c++/78572] handle array self references in intializers

2016-12-21 Thread Aldy Hernandez
On 12/20/2016 03:14 PM, Nathan Sidwell wrote: On 12/20/2016 01:52 PM, Aldy Hernandez wrote: int array[10] = { array[3]=5, 0x111, 0x222, 0x333 }; (gdb) x/4x &array 0x601040 : 0x0005 0x0111 0x0222 0x0005 That is, the array[3]=5 overwrites the last 0x333. I would

Re: [PR c++/78572] handle array self references in intializers

2016-12-20 Thread Nathan Sidwell
On 12/20/2016 01:52 PM, Aldy Hernandez wrote: int array[10] = { array[3]=5, 0x111, 0x222, 0x333 }; (gdb) x/4x &array 0x601040 : 0x0005 0x0111 0x0222 0x0005 That is, the array[3]=5 overwrites the last 0x333. I would expect that... That may be wrong. Using the

Re: [PR c++/78572] handle array self references in intializers

2016-12-20 Thread Aldy Hernandez
On 12/20/2016 11:48 AM, Nathan Sidwell wrote: On 12/20/2016 11:25 AM, Aldy Hernandez wrote: The problem in this PR is that we're trying to initialize an array with members of itself: Jakub has even gone further to show that for the following: ... = { array[3]=5, array[7]=3, array[7]=8, a

Re: [PR c++/78572] handle array self references in intializers

2016-12-20 Thread Nathan Sidwell
On 12/20/2016 11:25 AM, Aldy Hernandez wrote: The problem in this PR is that we're trying to initialize an array with members of itself: Jakub has even gone further to show that for the following: ... = { array[3]=5, array[7]=3, array[7]=8, array[7] = 9 }; things get even worse, because

[PR c++/78572] handle array self references in intializers

2016-12-20 Thread Aldy Hernandez
The problem in this PR is that we're trying to initialize an array with members of itself: int array[10] = { array[3]=5, array[7]=3 }; The C++ front-end, in store_init_value() via cxx_constant_value() and friends will transform: {array[3] = 5, array[7] = 3} into: {[