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

c++17 fold expression causes internal error

Tianhuan_L_
Beginner
366 Views

The fold expression will generate the following error message only when the value is not used:
"internal error: assertion failed: node_has_side_effects: bad node kind ... "

(compiled with icc -std=c++17)

template<int... I>
void f1(int* a)
{
    auto x = (a + ...);
}

template<int... I>
void f2(int* a)
{
    (a + ...);
}

void g()
{
    int a[1];
    f1<0>(a); // ok
    f2<0>(a); // internal error
}

Is there any solution to this problem?

0 Kudos
1 Reply
Viet_H_Intel
Moderator
366 Views

What compiler version you used?

$ cat t.cpp
template<int... I>
void f1(int* a)
{
    auto x = (a + ...);
}

template<int... I>
void f2(int* a)
{
    (a + ...);
}

void g()
{
    int a[1];
    f1<0>(a); // ok
    f2<0>(a); // internal error
}
$ icpc t.cpp -std=c++17 -c
$
$ icpc -V
Intel(R) C++ Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.0.5.281 Build 20190815
 

0 Kudos
Reply