Fix lambda-declarator by kazatsuyu · Pull Request #2333 · cplusplus/draft (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
The following code is well-formed.
[] () constexpr [[using std:]] noexcept {};
But the following code is currently ill-formed.
[] () [[using std:]] noexcept {};
I think it should be well-formed.
The following code is well-formed.
[] () constexpr [[using std:]] noexcept {};But the following code is currently ill-formed.
[] () [[using std:]] noexcept {};I think it should be well-formed.
I think this is not a correct change: attributes go after the noexcept-specifier, not before.
However, there are two bugs here:
[] () constexpr [[using std:]] noexcept {};should be ill-formed, but we don't prevent theconstexprdecl-specifier from having attributes.[] () constexpr [[]] {};is ambiguous, because there are two different _attribute-specifier-seq_s that could consume the attributes.
The fix would be to stop reusing decl-specifier-seq here, but this doesn't seem editorial to me.
More bugs caused by the reuse of decl-specifier-seq:
- [dcl.type]/3 says "Except in a declaration of a constructor, destructor, or conversion function, at least one defining-type-specifier that is not a cv-qualifier shall appear in a complete type-specifier-seq or a complete decl-specifier-seq.", which renders all
mutableorconstexpr_lambda-expression_s ill-formed. - Throughout [dcl.spec], wording assumes that a decl-specifier-seq has a corresponding init-declarator-list or member-declarator-list.
I think we simply should stop using decl-specifier_seq for lambdas. It was cute when constexpr was introduced, but the fall-out is scary plus we never actually refer to this as a decl-specifier-seq in the text that follows.
I have created a clean-up patch; see #2338. I hope to get CWG to review the issue in San Diego.
zygoloid added the not-editorial
Issue is not deemed editorial; the editorial issue is kept open for tracking.
label
Yes, the original issue is fixed with P1102R2. The decl-specifier-seq concerns will be addressed by #2338.
Labels
Issue must be reviewed by CWG.
The pull request needs a git rebase to resolve merge conflicts.
Issue is not deemed editorial; the editorial issue is kept open for tracking.