Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Matthias_H_3
Beginner
125 Views

Internal error (C++14 which ICC 16)

The (simplified) code:

#include <iostream>                                                                                                                                                                                                 
#include <type_traits>
using std::integral_constant;

template <int NUM> struct Cl_Iterate {
  template <typename FUNC> static void Do (FUNC f) {
    Cl_Iterate<NUM-1>::Do(f);
    f(integral_constant<int, NUM>());
  }
};

template <> struct Cl_Iterate<0> {
  template <typename FUNC> static void Do (FUNC f)  {   
      f(integral_constant<int,0>()); 
  }
};

template <int NUM, typename FUNC> void Iterate (FUNC f) {
  Cl_Iterate<NUM-1>::Do(f);
}

constexpr int N = 3;

// Breaks compiler:
// internal error: assertion failed at: "shared/cfe/edgcpfe/expr.c", line 31532
int g() {
    int ii=0;
    Iterate<N> ( [&] (auto i) {
        Iterate<1+i()> ( [&] (auto j ) { ii++; }); 
      }); 
}

// Works
int f() {
    int ii=0;
    Iterate<N> ( [&] (auto i) {
        int & kk = ii; 
        Iterate<1+i()> ( [&] ( auto j ) { kk++; }); 
      }); 
}

// Works
int h() {
    int ii=0;
    auto lambda = [&] ( auto j ) { ii++; };
    Iterate<N> ( [&] (auto i) {
        Iterate<1+i()> ( lambda );
      }); 
}

Note that in the original code a different assertion fails and a workaround as in g() and h() does not help.

I attached the preprocessed file from the original code, compile it with
icpc -openmp -std=c++1y -c l2hofe_preprocessed.cpp -o l2hofe.o

The assertion produced by the original code:
internal error: assertion failed at: "shared/cfe/edgcpfe/scope_stk.c", line 2025

icpc --version gives:
icpc (ICC) 16.0.0 20150501
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

I hope you can sort this out for the next (beta) update. We are eager to use this kind of 2 dimensional compile-time loop generation.

Regards,
Matthias Hochsteger

0 Kudos
2 Replies
Kittur_G_Intel
Employee
125 Views

Hi Matthias,
Thanks, yes I've filed this issue with the developers and will keep you updated on this accordingly. Appreciate your patience till then.
_Kittur 

 

Kittur_G_Intel
Employee
125 Views

Hi Matthias,
This issue is fixed in the latest update 2 release of the product which you can test it out, thanks.
Kittur

Reply