[Bug c++/61857] New: An init-capturing lambda is parsed incorrectly when used in a braced-init-list
ville.voutilainen at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Jul 20 12:27:00 GMT 2014
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61857
Bug ID: 61857
Summary: An init-capturing lambda is parsed incorrectly when
used in a braced-init-list
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: ville.voutilainen at gmail dot com
struct A {
A(int val){}
};
int main()
{
A a{ [x=123]{ return x; }() };
}
init-capture2.cpp: In function ‘int main()’:
init-capture2.cpp:7:11: error: ‘x’ was not declared in this scope
A a{ [x=123]{ return x; }() };
Clang recently fixed this bug, for clang it was caused by the parser
getting confused with the lambda and designated initializers, perhaps
gcc has a similar bug. With parentheses the code works:
struct A {
A(int val){}
};
int main()
{
A a( [x=123]{ return x; }() );
}
More information about the Gcc-bugs
mailing list