Skip to content

[dcl.attr.deprecated] Deprecating structured binding declarations #530

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

Closed
cor3ntin opened this issue Apr 25, 2024 · 1 comment
Closed

[dcl.attr.deprecated] Deprecating structured binding declarations #530

cor3ntin opened this issue Apr 25, 2024 · 1 comment

Comments

@cor3ntin
Copy link

[dcl.attr.deprecated]

Issue description:

The following code seem somewhat sensible, and there does not seem to be a a good reason for it to be disallowed

namespace binding {
  struct S { int i; }
  auto [G [[deprecated]]] = S{42};
  int test() {
    return G; // warn
  }
}

Suggested resolution:

The proposed warning mirror that of [[maybe_unused]]

Edit [dcl.attr.deprecated]/p2

The attribute may be applied to the declaration of a class, a typedef-name, a variable (including a structured binding declaration), a non-static data member, a function, a namespace, an enumeration, an enumerator, a concept, or a template specialization.

PS: The wording seemingly allows deprecating local variables, which seems of questionable usefulness.

@jensmaurer
Copy link
Member

This a (small) feature request, and thus needs a paper to EWG. I believe there is no doubt the status quo wording in the Working Draft is clear that this is ill-formed.

And the wording doesn't do what you want it to do; the "variable" here refers to the hidden variable that is declared by a structured binding declaration, where G refers to a subobject of that variable.

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