2015-02-23 19:30 GMT+00:00 Edward Catmur <
e...@catmur.co.uk>:
> From
http://stackoverflow.com/q/21294831/567292:
>
> struct S { int i; int j; };
> int f() { S s{5, s.i}; return s.j; }
>
> Is this defined behavior?
>
> [dcl.init.aggr]/2 has:
>>
>> When an aggregate is initialized by an initializer list, as specified in
>> 8.5.4, the elements of the initializer list
>> are taken as initializers for the members of the aggregate, in increasing
>> subscript or member order. Each
>> member is copy-initialized from the corresponding initializer-clause.
>
>
> [dcl.init.list]/4 has:
>>
>> Within the initializer-list of a braced-init-list, the
>> initializer-clauses, including any that result from pack
>> expansions (14.5.3), are evaluated in the order in which they appear. That
>> is, every value computation and
>> side effect associated with a given initializer-clause is sequenced before
>> every value computation and side
>> effect associated with any initializer-clause that follows it in the
>> comma-separated list of the initializer-list.
>
>
> The copy-initialization of an aggregate member is certainly a side effect,
> but is it "associated with" the corresponding initializer-clause or is that
> only intended to cover side-effects like in S s{++i, ++i}?
>
. My
the initializing full-expression. In your case, the situation appears