Skip to content

[basic.scope.scope] Remove incorrect namespace redeclaration example - #9241

Open
yehudamber wants to merge 1 commit into
cplusplus:mainfrom
yehudamber:patch-1
Open

[basic.scope.scope] Remove incorrect namespace redeclaration example#9241
yehudamber wants to merge 1 commit into
cplusplus:mainfrom
yehudamber:patch-1

Conversation

@yehudamber

Copy link
Copy Markdown

Since the adoption of P2996 "Reflection for C++26", and the changes it made to [namespace.alias], namespace aliases are no longer alternative names for namespaces but entities of their own kind. Therefore, redeclaring a namespace as a namespace alias, even denoting the original namespace, violates [basic.link]/11.3, since one declaration declares the entity as a namespace and the other does not.

Since the adoption of P2996 "Reflection for C++26", and the changes it made to [namespace.alias], namespace aliases are no longer alternative names for namespaces but entities of their own kind. Therefore, redeclaring a namespace as a namespace alias, even denoting the original namespace, violates [basic.link]/11.3, since one declaration declares the entity as a namespace and the other does not.
@eisenwave eisenwave added the P2-Bug Presentational errors and omissions label Aug 4, 2026
@timsong-cpp

timsong-cpp commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

If they are different entities, then [basic.link]/11.3 does not apply at all. That paragraph only applies to two declarations of the same entity.

Ah, [basic.link]/8 says that two declarations declare the same entity if they correspond (and various other things not relevant here), which they do since they introduce the same name. But that reasoning would seem to apply equally to typedef struct T T; and if so, that's definitely a defect.

@yehudamber

Copy link
Copy Markdown
Author

But that reasoning would seem to apply equally to typedef struct T T; and if so, that's definitely a defect.

Good point. I thought [basic.scope.scope]/4.2 covers such cases, but I see now it does not apply when the other declaration declares a type alias.
So maybe the rule at [basic.link]/8 is what needs to be fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2-Bug Presentational errors and omissions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants