cplusplus / cplusplus/draft

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

Open
#5,465 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

Description

[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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with [module.global.frag] paragraph 3 and the example involving S, S2, g, f, and the global namespace. Compare the decl-reachable wording with [basic.namespace.general] paragraph 3, which states that the global namespace has no declaration. Done means resolving whether the rule or example comment needs clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.