[Bug c++/87322] New: [GCC 8.1+] GCC fails to parse captured lambda of 2nd inner lambda if the captured lambda has "," (having 2 arguments)
hotguest1 at hotmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Sep 15 20:39:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87322
Bug ID: 87322
Summary: [GCC 8.1+] GCC fails to parse captured lambda of 2nd
inner lambda if the captured lambda has "," (having 2
arguments)
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: hotguest1 at hotmail dot com
Target Milestone: ---
Compiler thinks ',' in
inner_func2 = [] (auto a, auto b) { return a + b; }
is capture separation.
////////////////////////////////////////////////////////////
Reproducing code: https://godbolt.org/z/3h1ByQ
////////////////////////////////////////////////////////////
#include <array>
#include <algorithm>
int main()
{
constexpr std::array<std::array<double,2>,3> my_mat {
{ { 1., 1. },
{ 1., 1. },
{ 1., 1. }, }
};
std::for_each(my_mat.begin(), my_mat.end(), [
inner_func = [] (auto a, auto b) { return a + b; } ](auto& row) {
std::for_each(row.begin(), row.end(), [&,
inner_func2 = [] (auto a, auto b) { return a + b; } ]
(const double&) {
return;
});
});
}
////////////////////////////////////////////////////////////
Error:
////////////////////////////////////////////////////////////
<source>: In instantiation of 'main()::<lambda(auto:3&)> [with auto:3 = const
std::array<double, 2>]':
/opt/compiler-explorer/gcc-8.1.0/include/c++/8.1.0/bits/stl_algo.h:3882:5:
required from '_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter =
const std::array<double, 2>*; _Funct = main()::<lambda(auto:3&)>]'
<source>:19:4: required from here
<source>:15:58: internal compiler error: Segmentation fault
inner_func2 = [] (auto a, auto b) { return a + b; } ]
^
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1
More information about the Gcc-bugs
mailing list