Skip to content
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

[module.global.frag] Global namespace has no declaration how could it be "decl-reachable" from a declaration? #5465

Open
xmh0511 opened this issue May 12, 2022 · 0 comments

Comments

@xmh0511
Copy link
Contributor

xmh0511 commented May 12, 2022

[module.global.frag] p3 says

A declaration D is decl-reachable from a declaration S in the same translation unit if:

  • [...]
  • there exists a declaration M that is not a namespace-definition for which M is decl-reachable from S and either
  • [...]
  • D declares a namespace N and M is a member of N, or

The example after this rule has a case that:

template<typename> struct S;

template<typename, int> struct S2;

constexpr int g(int);

template<typename T, int N>
S<S2<T, g(N)>> f();             // S, S2, g, and ​::​ are decl-reachable from f

The declaration M(e.g. S, S2, g) is decl-reachable from S(e.g. f) and is a member of ::, however, ​::​ the global namespace does not have a declaration per [basic.namespace.general] p3

There is a global namespace with no declaration; see [basic.scope.namespace].

The comment is just a bit misleading. It appears to me that the emphasized wording only applies to the namespace that has a namespace-definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant