Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CWG2885 [class.default.ctor] Trivial default constructors should also be required to be eligible #184

Open
royjacobson opened this issue Nov 26, 2022 · 2 comments

Comments

@royjacobson
Copy link

Full name of submitter: Roy Jacobson

Reference (section label): [class.default.ctor]

Came up while thinking about this bug report - llvm/llvm-project#59206

Issue description:

The wording in [class.default.ctor]p3 says a base class or a member of a class need to have a trivial default constructors for a default constructor to be trivial.

Under the current wording, class B in the following example has a trivial default constructor, which is undesirable:

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

struct B : A {};

Suggested resolution:

 \item
-all the direct base classes of its class have trivial default constructors, and
+all the direct base classes of its class have eligible trivial default constructors, and

 \item
 for all the non-static data members of its class that are of class
-type (or array thereof), each such class has a trivial default constructor.
+type (or array thereof), each such class has an eligible trivial default constructor.
 \end{itemize}
@jensmaurer
Copy link
Member

I think we just want to defer to overload resolution, similar to what we do for (trivial) copy constructors.

@jensmaurer jensmaurer changed the title [class.default.ctor] Trivial default constructors should also be required to be eligible CWG2885 [class.default.ctor] Trivial default constructors should also be required to be eligible Apr 25, 2024
@jensmaurer
Copy link
Member

CWG2885

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants