Date
2016-02-15.00:00:00
Message id
5508

Content

[Adopted at the February, 2016 meeting.]

According to 11.4.5 [class.ctor] paragraph 4 says,

A defaulted default constructor for class X is defined as deleted if:

  • X is a union-like class that has a variant member with a non-trivial default constructor,

  • ...

This should make the following example ill-formed:

  struct S {
    S();
  };
  union U {
    S s{};
  } u;

because the default constructor of U is deleted. However, both clang and g++ accept this without error. Should the rule be relaxed for a union with an NSDMI?