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

GB-051 9.3.4.6 [dcl.fct], 9.3.4.7 [dcl.fct.default] Can an explicit object parameter have a default argument? #451

Closed
wg21bot opened this issue Oct 24, 2022 · 5 comments · Fixed by cplusplus/draft#5988
Labels
Milestone

Comments

@wg21bot
Copy link
Collaborator

wg21bot commented Oct 24, 2022

The syntax and semantics appear to allow:

struct S { void f(S* this = nullptr); };

This is probably no more than an oddity, but perhaps it should be prevented.

Strike this[opt] at the 2nd and 4th occurrence in the grammar of parameter-declaration.
Add a Note: an explicit-object-parameter-declaration cannot have an initializer-clause.

@wg21bot wg21bot added the EWG Evolution label Oct 24, 2022
@wg21bot wg21bot added this to the CD C++23 milestone Oct 24, 2022
@wg21bot wg21bot changed the title 9.3.4.6 [dcl.fct], 9.3.4.7 [dcl.fct.default] Can an explicit object parameter have a default argument? GB 9.3.4.6 [dcl.fct], 9.3.4.7 [dcl.fct.default] Can an explicit object parameter have a default argument? Oct 24, 2022
@jensmaurer jensmaurer changed the title GB 9.3.4.6 [dcl.fct], 9.3.4.7 [dcl.fct.default] Can an explicit object parameter have a default argument? GB-051 9.3.4.6 [dcl.fct], 9.3.4.7 [dcl.fct.default] Can an explicit object parameter have a default argument? Nov 3, 2022
@BengtGustafsson
Copy link

Maybe interesting as a clarification but as you can't avoid providing an implicit object parameter before the dot there is no way that the default argument would ever be used. I noted that at least in the MSVC implementation the pointer type is a function pointer (not a member function pointer), but this does not mean that a default expression would be usable.

@erichkeane
Copy link

Accept the proposed resolution to GB-051, and forward this to CWG.

SF F N A SA
7 8 5 0 0

Result: Consensus

@jfbastien jfbastien added CWG Core and removed EWG Evolution labels Nov 7, 2022
@erichkeane
Copy link

Note the example is incorrect, however the 'default'-ness issue was understood in the room.

struct S { void f(this const S &= S{}); };

@jensmaurer
Copy link
Member

CWG2653

@jensmaurer
Copy link
Member

jensmaurer commented Nov 8, 2022

CWG 2022-11-08: Accepted with Modifications. See CWG2653 for details.

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

Successfully merging a pull request may close this issue.

5 participants