Skip to content

[Clang] Valid candidate template function seems to be overlooked during explicit instantiation with specialized template class #121924

Open
@wangbo15

Description

Consider the following example:

template <class T>
struct A
{
    void f(T) {}
    template <typename MUT> void f(MUT t){}
};

template<>
struct A<int>
{
    void f(int) {}
    template <typename MUT> void f(MUT t){}
};

template
void A<int>::f(int);

Here the template function template<typename MUT> void f(MUT t) seems to be a feasible candidate for the explicit template function instantiation, but clang does not notice that:

<source>:16:14: error: explicit instantiation refers to member function 'A<int>::f' that is not an instantiation
   16 | void A<int>::f(int);
      |              ^
<source>:11:10: note: explicit instantiation refers here
   11 |     void f(int) {}
      |          ^
1 error generated.

GCC, EDG, and MSVC accept that: https://godbolt.org/z/qs1Tcr5s6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"diverges-from:edgDoes the clang frontend diverge from edg compilerdiverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions