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

2024-04-18


1301. Value initialization of union

Section: 9.4  [dcl.init]     Status: CD3     Submitter: Jason Merrill     Date: 2011-04-18

[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]

According to 9.4 [dcl.init] paragraph 7,

To value-initialize an object of type T means:

This suggests that for

  struct A { A() = delete; };
  union B { A a };
  int main()
  {
    B();
  }

a B temporary is created and zero-initialized, even though its default constructor is deleted. We should strike "non-union" and also the "if...non-trivial" condition, since we can have a trivial deleted constructor.

Proposed resolution (August, 2011):

  1. Change 9.4 [dcl.init] paragraph 7 as follows:

  2. To value-initialize an object of type T means:

  3. Change 9.4.5 [dcl.init.list] paragraph 3 as follows:

  4. List-initialization of an object or reference of type T is defined as follows:

This resolution also resolves issues 1324 and 1368.