https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83856
Bug ID: 83856
Summary: ICE in tsubst_copy;
Product: gcc
Version: 7.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kretz at kde dot org
Target Milestone: ---
Testcase (cf. https://godbolt.org/g/jFkk7N):
```
#include <array>
template <class T> struct simd
{
static constexpr size_t size() { return 4; }
template <class F> simd(F &&gen, decltype(std::declval<F>()(0)) * = nullptr)
{}
};
template <class V, class... F>
void test_tuples(const std::initializer_list<std::array<float, 1>> &data,
F &&... fun_pack)
{
auto it = data.begin();
const int remaining = data.size() % V::size();
if (remaining > 0) {
[](auto...) {
}((fun_pack(V([&](auto i) { return it[i < remaining ? i : 0][0]; })),
0)...);
}
}
void f()
{
test_tuples<simd<float>>({}, [](simd<float> x) {});
}
```
Output when compiling with GCC g++-7 (Ubuntu 7.2.0-1ubuntu1~16.04) 7.2.0:
```
ice.cpp: In instantiation of ‘test_tuples(const
std::initializer_list<std::array<float, 1> >&, F&& ...)::<lambda(auto:2)> [with
auto:2 = int; V = simd<float>; F = {f()::<lambda(simd<float>)>}]’:
ice.cpp:6:62: required by substitution of ‘template<class F>
simd<float>::simd(F&&, decltype (declval<F>()(0))*) [with F = test_tuples(const
std::initializer_list<std::array<float, 1> >&, F&& ...) [with V = simd<float>;
F = {f()::<lambda(simd<float>)>}]::<lambda(auto:2)> ’
ice.cpp:17:17: required from ‘void test_tuples(const
std::initializer_list<std::array<float, 1> >&, F&& ...) [with V = simd<float>;
F = {f()::<lambda(simd<float>)>}]’
ice.cpp:23:52: required from here
ice.cpp:14:25: internal compiler error: in tsubst_copy, at cp/pt.c:14539
const int remaining = data.size() % V::size();
^~~~
0x5eb5c2 tsubst_copy
../../src/gcc/cp/pt.c:14539
0x5ef666 tsubst_copy
../../src/gcc/cp/pt.c:14515
0x5ef666 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17831
0x5ef450 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:16769
0x5ef549 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17611
0x5ef086 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17232
0x5ef748 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:16934
0x5e83c7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:16550
0x5e95f1 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:14477
0x5e95f1 tsubst_init
../../src/gcc/cp/pt.c:14483
0x5eb558 tsubst_copy
../../src/gcc/cp/pt.c:14681
0x5ef666 tsubst_copy
../../src/gcc/cp/pt.c:14515
0x5ef666 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17831
0x5ef765 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:16935
0x5ef81b tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:17477
0x5ef505 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:16967
0x5ef4e9 tsubst_copy_and_build(tree_node*, tree_node*, int, tree_node*, bool,
bool)
../../src/gcc/cp/pt.c:16965
0x5e83c7 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:16550
0x5e7f85 tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:15811
0x5e810b tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool)
../../src/gcc/cp/pt.c:16027
```
GCC 8 appears to be fixed.