/* File test.cpp */
int rand();
template<typename T>
struct s
{
int count() { return rand(); }
};
template<typename v>
int f(s<v> a)
{
int const x = a.count();
int r = 0;
auto l = [&](int& r)
{
for(int y = 0, yend = (x); y < yend; ++y)
{
r += y;
}
};
l(r);
}
template int f(s<float>);
int main()
{
}
Which triggers the gcc bug:
$ g++ -c test.cpp
test.cpp: In instantiation of 'f(s<v>)::<lambda(int&)> [with v = float]':
test.cpp:14:16: required from 'struct f(s<v>) [with v = float]::<lambda(int&)>'
test.cpp:14:10: required from 'int f(s<v>) [with v = float]'
test.cpp:24:24: required from here
test.cpp:16:24: internal compiler error: in maybe_undo_parenthesized_ref, at cp/semantics.c:1705
for(int y = 0, yend = (x); y < yend; ++y)
^~~~
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Notice that the same compilation error happens with the following commands
Issue: g++ fails with internal compiler error.
Consider a C++ program:
Which triggers the gcc bug:
Notice that the same compilation error happens with the following commands
but not with
Also note that g++ from Debian has a fix to the above bug, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882855 .
Environment (
conda list
):Details about
conda
and system (conda info
):