Title
Redeclaration of types and namespaces and their aliases
Status
open
Section
6.7 [basic.link]
Submitter
Yehuda Bernáth

Created on 2026-08-02.00:00:00 last changed 5 days ago

Messages

Date: 2026-08-09.11:57:10

Possible resolution:

Add bullets and change in 6.7 [basic.link] paragraph 8 as follows:

Two declarations of entities declare the same entity if, considering declarations of unnamed types to introduce their names for linkage purposes, if any (9.2.4 [dcl.typedef], 9.8.1 [dcl.enum]),
  • they correspond (6.4.1 [basic.scope.scope]),
  • both have the same target scope that is not a function or template parameter scope,
  • neither is a name-independent declaration, and
  • if either declares a type alias, both do,
  • if either declares a namespace alias, both do, and
  • either one of the following holds:
    • they appear in the same translation unit, or
    • they both declare type aliases or namespace aliases that have the same underlying entity, or
    • they both declare names with module or external linkage and are attached to the same module.
[Note 3: There are other circumstances in which declarations declare the same entity (9.12 [dcl.link], 13.6 [temp.type], 13.7.6 [temp.spec.partial]). —end note]
Date: 2026-08-02.00:00:00

(From #9241.)

Consider:

  struct T;
  typedef struct T T;

According to 6.7 [basic.link] paragraph 8, these two declarations declare the same entity. However, type aliases are separate entities nowadays.

History
Date User Action Args
2026-08-09 11:57:10adminsetmessages: + msg8640
2026-08-02 00:00:00admincreate