Skip to content

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

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: cplusplus/papers#878 (comment)

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.

Activity

  1. eisenwave commented on Mar 10, 2025

    @eisenwave
    MemberAuthor

    Note that cplusplus/draft#7728 also changes the same paragraph; maybe we can do that editorial change as a drive-by in here.

  2. jensmaurer commented on Mar 11, 2025

    @jensmaurer
    Member
  3. changed the title [-][basic.scope.scope] Function parameters can be name-independent[/-] [+]CWG3005 [basic.scope.scope] Function parameters can be name-independent[/+] on Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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