Bug 49326 - Lambda arguments should not have a default value
Summary: Lambda arguments should not have a default value
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.1
: P3 trivial
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2011-06-08 16:40 UTC by Ruben Van Boxem
Modified: 2011-06-08 17:48 UTC (History)
0 users

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Ruben Van Boxem 2011-06-08 16:40:23 UTC
Currently, GCC 4.6.1 warns in pedantic mode when a lambda is written that provides  default value for an argument:

[](bool a, bool=true){ return !a;} }

Which, according to the FDIS n3290 section 5.1.2/5, should be illegal and thus give an error. 

As the detection code is already present/functional (in -pedantic mode), changing that into an error shouldn't be hard.
Comment 1 Jonathan Wakely 2011-06-08 16:50:42 UTC
If you get a warning with -pedantic that usually means it's a G++ extension.

If you don't want the extension use -pedantic-errors so it is rejected
Comment 2 Ruben Van Boxem 2011-06-08 16:54:34 UTC
I compiled with -std=c++0x, so GCC extensions should be turned off.
Comment 3 Jonathan Wakely 2011-06-08 17:05:06 UTC
No, that's not how it works, read the manual for -std and -pedantic.
Comment 4 Ruben Van Boxem 2011-06-08 17:48:53 UTC
Ok, my mistake, I compiled with -std=c++0x -pedantic, which (as I'm reading in the manual now) turns off GCC extensions and makes  program adhere to strict standards... But emits warnings only. I should use -pedantic-errors then. OK. That works as it should in this case. Thanks.