-
Notifications
You must be signed in to change notification settings - Fork 7
CWG2992 [basis.pre] Are labels names? #673
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
Comments
I was pointed out to the fact that identifiers in attributes might be suffering from a similar wording defect. Given that they are explicitly exempted from undergoing name lookup, maybe they shouldn't be considered names either. The more radical approach to fixing both issues would be to merge p3 and p5, saying that the grammar productions from p3 are names when they are a part of declarations listed in p5. This would eliminate all defects along the lines "it's an identifier, hence a name per p3, but it doesn't fit what p5 says." |
I think it would be better to make p5 less restrictive.
|
No. Labels are not names (because they are not subject to name lookup). |
@jensmaurer I still think @frederick-vs-ja 's suggestion would be an improvement here! |
Wouldn't this make label a name, because it satisfies p3? |
I think the conceptual model after P1787R6 is:
Now, uses of identifier labels do not interfere with declarations or name lookup. The fact that an identifier is a name does not matter at all. This means [basic.pre]/3 is fine, but [basic.pre]/5 is problematic.
Here is another example which shows that [basic.pre]/5 is problematic: auto f(auto a) { g(a); }
|
I disagree; I want the inverse approach. Labels and attributes are simply not names, and any statement to the contrary needs to be fixed. For your |
Then we need to turn https://eel.is/c++draft/dcl.attr#grammar-4.sentence-6 into a note, and say that identifiers within attribute-specifiers are not names, too. |
Why do you care if they are names or not? It doesn't matter at all.
Let's suppose that
This doesn't cause the name |
I do care because I don't want "names" to exist that are not declared and/or not subject to name lookup. I find it a more consistent overall picture to have a "name" only where that implies a connection to name lookup. Regarding |
|
It seems to me that this example shows an unfortunate fact: theoretically, the validness of this function template can't be determined locally, and we can only consider well-formedness of the whole program in this case. |
[basic.pre]/3:
I believe the definition for name includes
identifier
withinlabel
([stmt.label]):However, [basic.pre]/5 states that:
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:
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:
The text was updated successfully, but these errors were encountered: