Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
14 Views

c++17 fold expression causes internal error

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
Highlighted
Moderator
14 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