Title
Specializations for a class are not decl-reachable
Status
open
Section
10.4 [module.global.frag]
Submitter
Davis Herring

Created on 2024-12-19.00:00:00 last changed 3 days ago

Messages

Date: 2024-12-19.00:00:00

(From submission #655.)

Consider:

  module;
  // included...
  template<int> struct X {};
  template<> struct X<0> {};
  struct Z;
  template<class> struct Y {};
  template<> struct Y<Z> {};
  // ...done
  export module M;
  export using ::X;
  export using ::Z;

Subclause 10.4 [module.global.frag] bullet 3.5.7 implies that X<0>, but not Y<Z> is reachable in importers. This is not helpful when Y is a trait defined by another library and specialized for the library being exposed as M.

Possible resolution:

Change in 10.4 [module.global.frag] bullet 3.5 as follows:

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 is decl-reachable from M , or
    • D and M declare the same entity, and D neither is a friend declaration nor inhabits a block scope, or
    • D declares a namespace N and M is a member of N , or
    • one of D and M declares a class or class template C and the other declares a member or friend of C, or
    • one of D and M declares an enumeration E and the other declares an enumerator of E, or
    • D declares a function or variable and M is declared in D, [ Footnote: ... ] or
    • one of D and M declares a template and the other declares a partial or explicit specialization or an implicit or explicit instantiation of that template, or
    • D declares a partial or explicit specialization or an explicit instantiation and M declares an entity that appears in D's (possibly deduced) template arguments, or
    • M declares a class template and D is a deduction guide for that template, or
    • one of D and M declares a class or enumeration type and the other introduces a typedef name for linkage purposes for that type.
History
Date User Action Args
2024-12-19 00:00:00admincreate