Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Failure to compile code containing function templates.

Dmitry_Z_3
Beginner
223 Views

The included example compiles (and runs) in GCC 5.1, but ICC fails with the following internal error:
                   assertion failed at: "shared/cfe/edgcpfe/il.c", line 18463

#include "stdafx.h"

#include <utility>
#include <array>
#include <iostream>

template <size_t... I, size_t... J>
constexpr std::array<char, sizeof...(I) + sizeof...(J) + 1>
constcat_impl(
	const char (&s)[sizeof...(I) + 1],
	const char (&t)[sizeof...(J) + 1],
	std::index_sequence<I...>,
	std::index_sequence<J...>) {
	return{ s..., t..., '\0' };
}

template <size_t M, size_t N, 
    typename I = std::make_index_sequence<M - 1>,
    typename J = std::make_index_sequence<N - 1>>
constexpr std::array<char, M + N - 1>
constcat(const char (&s), const char (&t)) {
	return constcat_impl(s, t, I(), J());
}

int main()
{
	auto a = constcat("Hello, ", "world!");
	std::cout << a.data() << std::endl;
	return 0;
}

 

0 Kudos
2 Replies
Anoop_M_Intel
Employee
223 Views

Thanks for reporting this issue. I can reproduce this problem and have escalated to compiler engineering.

Regards
Anoop

0 Kudos
Anoop_M_Intel
Employee
223 Views

This issue is fixed in 17.0 compiler which is available at Intel Registration Center.

Thanks and Regards
Anoop

0 Kudos
Reply