[llvm-bugs] [Bug 27152] New: cannot expand parameter pack of base classes outside the deriving class

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 30 20:15:54 PDT 2016


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

            Bug ID: 27152
           Summary: cannot expand parameter pack of base classes outside
                    the deriving class
           Product: clang
           Version: 3.7
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: amidvidy at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

See example code that compiles with gcc-5.3 but not clang++ 3.7

======================================
#include <iostream>

class Base1 {
public:
    void foo() {
        std::cout << "Base1" << std::endl;
    }
};

class Base2 {
public:
    void foo() {
        std::cout << "Base2" << std::endl;
    }
};

template <typename... Bases>
class Derived : public Bases... {
};

template<typename... Bases>
void call_foo_on_bases(Derived<Bases...> derived) {
    using expander = int[];
    (void) expander {0, (derived.Bases::foo(), 0)...};
}

int main() {
    call_foo_on_bases(Derived<Base1, Base2>());
}
==============================

The compile fails with this error using clang++ 3.7 -

main.cpp:31:50: error: pack expansion does not contain any unexpanded parameter
packs
    (void) expander {0, (derived.Bases::foo(), 0)...};


Interestingly, if we change the above code to expand the pack of base classes
within the derived class, it compiles correctly (.e.g.)

// WORKS!
template <typename... Bases>
class Derived : public Bases... {
public:
    void call_foo_on_bases() {
        using expander = int[];
        (void) expander {0, (Bases::foo(), 0)... };
    }
};

-- 
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/20160331/8bffeae1/attachment.html>


More information about the llvm-bugs mailing list