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

Fix lambda-declarator #2333

Closed
wants to merge 1 commit into from
Closed

Fix lambda-declarator #2333

wants to merge 1 commit into from

Conversation

kazatsuyu
Copy link

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.
@zygoloid
Copy link
Member

zygoloid commented Sep 15, 2018

I think this is not a correct change: attributes go after the noexcept-specifier, not before.

However, there are two bugs here:

  1. [] () constexpr [[using std:]] noexcept {}; should be ill-formed, but we don't prevent the constexpr decl-specifier from having attributes.
  2. [] () constexpr [[]] {}; is ambiguous, because there are two different attribute-specifier-seqs that could consume the attributes.

The fix would be to stop reusing decl-specifier-seq here, but this doesn't seem editorial to me.

@zygoloid zygoloid added the cwg Issue must be reviewed by CWG. label Sep 15, 2018
@zygoloid
Copy link
Member

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 mutable or constexpr lambda-expressions ill-formed.
  • Throughout [dcl.spec], wording assumes that a decl-specifier-seq has a corresponding init-declarator-list or member-declarator-list.

@jensmaurer
Copy link
Member

jensmaurer commented Sep 22, 2018

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.

@jensmaurer
Copy link
Member

I have created a clean-up patch; see #2338. I hope to get CWG to review the issue in San Diego.

@zygoloid zygoloid added the not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking. label Nov 6, 2018
@jensmaurer jensmaurer added the needs rebase The pull request needs a git rebase to resolve merge conflicts. label Apr 4, 2021
@tkoeppe
Copy link
Contributor

tkoeppe commented Jun 19, 2021

@jensmaurer: does https://wg21.link/p1102r2 fix the underlying issue?

@jensmaurer
Copy link
Member

jensmaurer commented Jun 20, 2021

Yes, the original issue is fixed with P1102R2. The decl-specifier-seq concerns will be addressed by #2338.

@jensmaurer jensmaurer closed this Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cwg Issue must be reviewed by CWG. needs rebase The pull request needs a git rebase to resolve merge conflicts. not-editorial Issue is not deemed editorial; the editorial issue is kept open for tracking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants