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

2024-12-19


2885. Non-eligible trivial default constructors

Section: 11.4.5.2  [class.default.ctor]     Status: review     Submitter: Roy Jacobson     Date: 2022-11-26     Liaison: LWG

(From submission #521.)

Consider:

  template <class T>
  struct A {
    A() requires (false) = default;
    A() : t(42) {}
    T t;
  };

  struct B : A<int> {};

According to the current wording, class B has a trivial default constructor, which is undesirable.

Proposed resolution (approved by CWG 2024-05-31):

Change in 11.4.5.2 [class.default.ctor] paragraph 3 as follows:

A default constructor for class X is trivial if it is not user-provided and if: Otherwise, the default constructor is non-trivial.