https://bugs.llvm.org/show_bug.cgi?id=52025

            Bug ID: 52025
           Summary: clang cannot deduce return type for the implicit
                    instantiation of template specialization
           Product: clang
           Version: 12.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++14
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

The following code fails to compile, however must to.

template <typename T>
struct S
{
    template <typename U>
    decltype(auto) operator[](U u);
};

template <>
template <typename U>
decltype(auto) S<int>::operator[](U u)
{
    return u;
}

int main()
{
    S<int> s;
    std::cout << s[1] <<std::endl;
    return 0;
}

https://godbolt.org/z/MqqY5cTjx

Impicit instantiation of S<int> definition implies implicit instantiation of
the operator[] template declaration at the line
13(https://eel.is/c++draft/temp#inst-3.1). After that a[1] shall be resolved in
favor of declaration instantiated from template at the line
13(https://eel.is/c++draft/temp#inst-10), which implies implicit instantiation
of the operator[] definition(https://eel.is/c++draft/temp#inst-4), which allows
compiler to deduce return
type(https://eel.is/c++draft/dcl.spec.auto#general-12)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to