https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71841
Bug ID: 71841 Summary: variadic template can't cast to base class Product: gcc Version: 5.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: johan.leroy at openehs dot co.uk Target Milestone: --- Also with version 6.0 Following example compiles and run on Visual Studio and CLang template<IItem* ...aItem> class Item : public IItem { private: static constexpr size_t c_NumberOfChilderen = (sizeof...(aItem) > 0 ? sizeof...(aItem) : 1); public: IItem* RootItem; IItem* ChildItem[c_NumberOfChilderen] = { aItem... }; Item() { for (size_t x = 0; x < sizeof...(aItem); x++) { ChildItem[x]->SetRoot(this); } } void printTree(int level) { for (int y = 0; y < level; y++) printf("\t"); printf("%p\n", this); for (size_t x = 0; x < sizeof...(aItem); x++) { ChildItem[x]->printTree(level + 1); } } void SetRoot(IItem* RootItem) { RootItem = RootItem; } private: }; Item<> Level10; Item<> Level11; Item<reinterpret_cast<IItem*>(&Level11), reinterpret_cast<IItem*>(&Level10)> ItemLevel00; int main() { ItemLevel00.printTree(0); return 0; } //Error from GCC ../src/main.cpp:53:76: error: could not convert template argument '(IItem*)(& Level11)' to 'IItem*' Item<reinterpret_cast<IItem*>(&Level11), reinterpret_cast<IItem*>(&Level10)> ItemLevel00; ^ ../src/main.cpp:53:76: error: could not convert template argument '(IItem*)(& Level10)' to 'IItem*' ../src/main.cpp: In function 'int main()': ../src/main.cpp:57:14: error: request for member 'printTree' in 'ItemLevel00', which is of non-class type 'int' ItemLevel00.printTree(0);