Skip to Main Content

Template parameter pack causes compiler assertion

Jacob BarrettJun 10 2017 — edited Jun 14 2017

When using template parameter pack to avoid spelling out every parameter on heavily parameterized templates, like std::unordered_map, the compiler stops with an assertion error. I have been able to reproduce it with a simple test source against std::vector and attached that source.

I have since removed the use of template parameter pack and explicitly write out each parameter but wanted to pass this along should anyone else run into it or Oracle wanted to fix the compiler.

The following test source results in a compiler assertion:

#include <vector>

template<class _head, class ... _tail>

void doSomething(const std::vector<_head, _tail...>& v) {

}

template<class T>

class Vector : public std::vector<T> {

  void callDoSomething() {

    ::doSomething(*this);

  }

};

template class Vector<int>;

int main(void) {

}

Compiler output with 12.6 beta (Studio 12.6 Sun C++ 5.15 SunOS_i386 Beta 2016/12/19 (HASH: be2652d6c8b6)):

$ CC -std=c++11 test.cpp             

>> Assertion:   (../lnk/substitute.cc, line 3041)

    while processing test.cpp at line 0.

The problem also exists in the 12.5 version as well.

-Jake

Comments
Post Details
Added on Jun 10 2017
1 comment
127 views