This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 113d. See for the official list.


1397. Class completeness in non-static data member initializers

Section: 11.4  [class.mem]     Status: CD4     Submitter: Jason Merrill     Date: 2011-09-23

[Moved to DR at the November, 2014 meeting.]

In Bloomington there was general agreement that given a class that uses non-static data member initializers, the exception-specification for the default constructor depends on whether those initializers are noexcept. However, according to 11.4 [class.mem] paragraph 2, the class is regarded as complete within the brace-or-equal-initializers for non-static data members.

This suggests that we need to finish processing the class before parsing the NSDMI, but our direction on issue 1351 suggests that we need to parse the NSDMI in order to finish processing the class. Can't have both...

Additional note (March, 2013):

A specific example:

  struct A {
    void *p = A{};
    operator void*() const { return nullptr; }

Perhaps the best way of addressing this would be to make it ill-formed for a non-static data member initializer to use a defaulted constructor of its class.

See also issue 1360.

Notes from the September, 2013 meeting:

One approach that might be considered would be to parse deferred portions lazily, on demand, and then issue an error if this results in a cycle.

Proposed resolution (February, 2014):

Change 11.4 [class.mem] paragraph 4 as follows:

A brace-or-equal-initializer shall appear only in the declaration of a data member. (For static data members, see []; for non-static data members, see 11.9.3 [class.base.init]). A brace-or-equal-initializer for a non-static data member shall not directly or indirectly cause the implicit definition of a defaulted default constructor for the enclosing class or the exception-specification of that constructor.