cplusplus / CWG

Core Working Group
23 stars 7 forks source link

[temp.inst] p3 Lacks the wording for the syntax checking in instantiated declaration caused by implicit instantiation #360

Open xmh0511 opened 1 year ago

xmh0511 commented 1 year ago

Full name of submitter (unless configured in github; will be published with the issue): Jim X

Consider the contrasting examples:

template<bool r>
struct S{
   template<class  = std::enable_if_t<r>>
   void show(){}
};
int main(){
    S<false> s;  // #1
}
template<bool r>
struct S{
   template<class U = bool, class  = std::enable_if_t<U(r)>>
   void show(){}
};
int main(){
    S<false> s;  // #2
}

#1 cause the program ill-formed but #2 does not. However, [temp.inst] p3 merely has a brief phrase:

The implicit instantiation of a class template specialization causes

  • the implicit instantiation of the declarations, but not of the definitions, of the non-deleted class member functions, member classes, scoped member enumerations, static data members, member templates, and friends; and
  • the implicit instantiation of the definitions of deleted member functions, unscoped member enumerations, and member anonymous unions.

There is no wording in the standard to specify how the further syntax checking would perform for an instantiated declaration, after all, the instantiated declaration is not a source-level code.