[llvm-bugs] [Bug 25483] New: Injected base class name not available when CRTP base class is instantiated using a subclass that is itself a template instantiation.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 10 18:09:00 PST 2015


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

            Bug ID: 25483
           Summary: Injected base class name not available when CRTP base
                    class is instantiated using a subclass that is itself
                    a template instantiation.
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: paul.ryan.harvey at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

An injected base class name is not available to be used as a constructor when a
CRTP base class is instantiated using a subclass that is itself a template
instantiation.

The following works as expected:

template <typename>
struct A {};

struct B : public A<B> {
    B() : A() {}
};

int main()
{
  B b;
}

The following results in: error: member initializer 'A' does not name a
non-static data member or base class

template <typename>
struct A {};

template <typename T>
struct B : public A<B<T>> {
  B() : A() {}
};

int main()
{
  B<void> b;
}

The following workaround is available:

template <typename T>
struct B : public A<B<T>> {
  using A = A<B>;
  B() : A() {}
};

-- 
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/20151111/97648e4d/attachment.html>


More information about the llvm-bugs mailing list