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 we generate code to write twice into [3]: {[3]=5, [0]=5, [7]=9, [1]=3, [2]=8, [3]=9}
I looked at this a couple of weeks ago, and got confused. It wasn't very clear to me how the side-effect assignments interact with any implict zero assignments. (Especially if one then tries to support C-style designated initializers).
IIUC the side effects of an initializer are evaluated before the storage of the initializer itself (separated by a sequence point). further it seems that default zero initialization of non-explicitly initialized elements happens after any side-effected store to that element (and hence zaps the sideeffect). The rules for non-aggregates appear to be as-if one builds a temporary object and then copy-constructs it into the object -- clearly zapping any and all side-effects. However for aggregate initializations it looked like elements were initialized in order -- so the side effect on a later element could overwrite the initialization of an earlier element.
It wasn't entirely clear. nathan -- Nathan Sidwell