https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66999
Bug ID: 66999
Summary: Missing comma in lambda capture causes internal
compiler error
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: paradise at fb dot com
Target Milestone: ---
I found a spot in some code where I was missing a comma between two values in
the lambda capture, so instead of "[i, &d]" I had "[i &d]". In older versions
of GCC (4.8.1 and 4.9 tested) it actually compiled this without complaining,
and appears to capture both i and d. In GCC 5.1.0 and 5.2.0, it fails to
compile with an internal compiler error:
13 : internal compiler error: in ~saved_token_sentinel, at cp/parser.c:1199
--------------------------------------------------------------------------
#include <iostream>
#include <thread>
using namespace std;
int main(int argc, char* argv[]) {
int i = 1;
int d = 2;
auto f = thread([
i &d] () {
// If you comment out the next two lines, this doesn't compile
auto p = d;
//std::cout << p << std::endl;
std::cout << i << std::endl;
std::cout << d << std::endl;
return 0;
});
return 0;
}
--------------------------------------------------------------------------
Compiler options: -std=c++11 -O2 -Wall -Wextra
gcc.godbolt.org explorer for this: http://goo.gl/CCVpRP