[llvm-bugs] [Bug 52025] New: clang cannot deduce return type for the implicit instantiation of template specialization

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Sep 30 11:38:59 PDT 2021


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: unassignedclangbugs at nondot.org
          Reporter: harashimahashi at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210930/3083c17a/attachment.html>


More information about the llvm-bugs mailing list