[Bug c++/101771] New: The keyword "typename" is illegal used in a using-declaration that introduces the non-type declarations

xmh970252187 at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Aug 4 02:48:59 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101771

            Bug ID: 101771
           Summary: The keyword "typename" is illegal used in a
                    using-declaration that introduces the non-type
                    declarations
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: xmh970252187 at gmail dot com
  Target Milestone: ---

struct C{
    void fun(){}
};
template<class T>
struct D:T{
    using typename T::fun;  // #1
};
int main(){
    D<C> b;  
}

According to [temp.res#general-5] 

>A qualified-id whose terminal name is dependent and that is in a type-only context is considered to denote a type. A name that refers to a using-declarator whose terminal name is dependent is interpreted as a typedef-name if the using-declarator uses the keyword typename.

`fun` in #1 is interpreted to a typedef-name

Meanwhile, according to [temp.res#general-6.5]
> The validity of a template may be checked prior to any instantiation. The program is ill-formed, no diagnostic required, if:

>> the interpretation of such a construct in the hypothetical instantiation is different from the interpretation of the corresponding construct in any actual instantiation of the template.  

The actual instantiation of `D<C>` would make `fun` denotes a function rather
than denotes a type. Hence, it should be illegal.


More information about the Gcc-bugs mailing list