This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


155. Brace initializer for scalar

Section: 9.4  [dcl.init]     Status: dup     Submitter: Steve Clamage     Date: 12 Aug 1999

It is not clear whether the following declaration is well-formed:

    struct S { int i; } s = { { 1 } };
According to 9.4.2 [dcl.init.aggr] paragraph 2, a brace-enclosed initializer is permitted for a subaggregate of an aggregate; however, i is a scalar, not an aggregate. 9.4 [dcl.init] paragraph 13 says that a standalone declaration like
    int i = { 1 };
is permitted, but it is not clear whether this says anything about the form of initializers for scalar members of aggregates.

This is (more) clearly permitted by the C89 Standard.

Rationale (May, 2008):

Issue 632 refers to exactly the same question and has a more detailed discussion of the considerations involved.