Skip to content

CWG3005 [basic.scope.scope] Function parameters can be name-independent #681

Open
@Eisenwave

Description

@Eisenwave

Reference (section label): [basic.scope.scope] pargraph 5, bullet 1

Link to reflector thread (if any):

Issue description

From P2169R4:

In Varna, EWG decided not to support function parameter names and requires clauses parameter as these can remained unamed without semantics differences.

See also poll: https://github.com/cplusplus/papers/issues/878#issuecomment-1594534611

This design was not worded correctly because [basic.scope.scope] paragraph 5, bullet 1 permits all variables with automatic storage duration named _ to be name-independent, including function parameters.

Suggested resolution

Change [basic.scope.scope] paragraph 5 as follows:

A declaration is name-independent if its name is _ (U+005F LOW LINE) and it declares

  • a variable with automatic storage duration other than a function parameter,
  • a structured binding with no storage-class-specifier and not inhabiting a namespace scope,
  • the variable introduced by an init-capture, or
  • a non-static data member of other than an anonymous union.

Recommended practice: Implementations should not emit a warning that a name-independent declaration is used or unused.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions