Skip to content

CWG2992 [basis.pre] Are labels names? #673

Description

@Endilll

[basic.pre]/3:

A name is an identifier ([lex.name]), conversion-function-id ([class.conv.fct]), operator-function-id ([over.oper]), or literal-operator-id ([over.literal]).

I believe the definition for name includes identifier within label ([stmt.label]):

label:
attribute-specifier-seqopt identifier :

However, [basic.pre]/5 states that:

Every name is introduced by a declaration <...>

Which is at odds with the fact that labels fit into the definition of name, but are statements, and not declarations.

P1787R6 "Declarations and where to find them" made major changes to the definition of name with the following intent:

Because labels interact with so little of the language, their identifiers are excluded from names and name lookup entirely.

It seems that the definition of name should be updated to make it clear that labels are not included.

Suggested resolution (2025-02-20):

Convert [basic.pre] paragraph 3 into a bulleted list, and apply the following changes:

A name is

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions