Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

ICE on variadic template code

$
0
0

Compile the following testcase with /opt/intel/composer_xe_2013_sp1.3.174/bin/intel64/icpc -O0 -std=c++11 -c

struct V {
  static constexpr int Size = 1;
};

template <typename To, typename From> inline To cast(From x);

template <int N, int = 1> struct sarray {
  typedef sarray<N / 2> S;
  sarray foo() const { const auto b = d.foo().bar(); }
  sarray bar() const { return {cast<S>(d)}; }
  S d;
};
template <int N> struct sarray<N, N> {
  static constexpr int Size = 1;
  sarray foo() const {}
  sarray bar() const {}
  V d;
};

template <typename To, typename From, typename... Froms>
inline To drop_arguments(Froms..., From, From);

template <typename To, typename From, typename... Froms>
inline To cast(From x, Froms... xs)
{
  using R0 = typename To::S;
  return {drop_arguments<R0, Froms...>(x, xs...)};
}

template <typename To, int N, typename... From>
inline To cast(const sarray<N, N> &x0, const From &... xs)
{
  return cast<To>(x0.d, xs.d...);
}

template <typename To, int N, int M, typename... From>
inline To cast(const sarray<N, M> &x0, const From &... xs)
{
  return cast<To>(x0.d, xs.d..., x0.d, xs.d...);
}

template <typename To, typename From, typename... Froms>
inline To drop_arguments(Froms..., From, From)
{
}

void test() { sarray<8>().foo(); }

​This is the output I get:

​icc-ice.cpp(37): internal error: assertion failed at: "shared/cfe/edgcpfe/func_def.c", line 1576



  {

  ^



compilation aborted for icc-ice.cpp (code 4)

PS: I tried to report this to Intel Premier Support, but once again that site is broken ... :-(


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>