[llvm-bugs] [Bug 29158] New: Nested template class partial specialization cannot be used

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Aug 27 08:54:16 PDT 2016


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

            Bug ID: 29158
           Summary: Nested template class partial specialization cannot be
                    used
           Product: clang
           Version: 3.7
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bondvladserg at mail.ru
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

Define a class with members in following sequence:
1) forward declaration of nested class.
2) usage of this nested class specialization before definition/specialization.
3) definition + specialization

Result: specialization never used in this case

I'm not sure if it is clang bug, but it works on GCC and VS compilers.

Code sample:

#include <iostream>

template<typename T>
struct Foo
{
    // Dummy for PARTIAL specialization
    // because full specialization is not allowed
    template<typename T2, typename Dummy>
    struct Bar;

    using Type = typename Bar<T, void>::Type;

    template<typename T2, typename Dummy>
    struct Bar
    {
        using Type = T2;
    };
    template<typename Dummy>
    struct Bar<double, Dummy>
    {
        using Type = char;
    };
};

int main()
{
    static_assert(sizeof(Foo<int>::Type) == sizeof(int),
"sizeof(Foo<int>::Type) != sizeof(int)");
    static_assert(sizeof(Foo<double>::Type) == sizeof(char),
"sizeof(Foo<double>::Type) != sizeof(char)");
}

Related question on StackOverflow:
http://stackoverflow.com/questions/39180110/clang-fatal-error-recursive-template-instantiation-exceeded-maximum-depth

-- 
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/20160827/cc509d33/attachment.html>


More information about the llvm-bugs mailing list