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

Is it intended that an aggregate with a deleted or nonexistent default constructor satisfy DefaultConstructible? #300

Closed
timsong-cpp opened this issue Dec 5, 2016 · 3 comments

Comments

@timsong-cpp
Copy link
Contributor

timsong-cpp commented Dec 5, 2016

For example, given

struct A{
    A(const A&) = default;
};

The following expressions are all valid:

A{};
new A{};
new A[5]{};

which would seem to mean that A meets DefaultConstructible as defined in [concepts.lib.object.defaultconstructible], unless I missed something.

If this is intended, then the note in [concepts.lib.object.defaultconstructible] is incorrect.

Proposed Resolution

See P0547R1.

@CaseyCarter
Copy link
Collaborator

CaseyCarter commented Dec 5, 2016

Close enough to intended, though I'm interested to get feedback from users on our choice of list-initialization for Constructible et al.

Proposed Resolution:

Modify the note in [concepts.lib.object.defaultconstructible]/1 as follows:
1 [ Note: The array allocation expression new T[n]{} implicitly requires that T
- has a non-explicit
+ does not have an explicit
default constructor. --end note ]

@CaseyCarter
Copy link
Collaborator

Committee discussion of this issue needs to consider the fact that this implies the existence of DefaultConstructible types T for which the declaration T foo; is ill-formed. This is enough of a freakish corner case that I'm happy to leave it ill-formed and let the fix be "don't do that."

@ericniebler
Copy link
Owner

As with std::is_constructible, we can require DefaultConstructible to check the well-formed-ness of the statement T tmp;. That will require a compiler intrinsic, which makes it harder to implement the TS, but that may be a price worth paying. From googling around, I'll note the __is_constructible intrinsic already exists on MSVC 2013 and clang.

@CaseyCarter CaseyCarter added review and removed new labels Mar 4, 2017
@ericniebler ericniebler added ready and removed review labels Jul 12, 2017
CaseyCarter added a commit that referenced this issue Jul 18, 2017
CaseyCarter added a commit that referenced this issue Jul 18, 2017
CaseyCarter added a commit that referenced this issue Jul 18, 2017
CaseyCarter added a commit that referenced this issue Jul 18, 2017
CaseyCarter added a commit that referenced this issue Jul 18, 2017
CaseyCarter added a commit that referenced this issue Jul 18, 2017
CaseyCarter added a commit that referenced this issue Jul 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants