Bug 49326

Summary: Lambda arguments should not have a default value
Product: gcc Reporter: Ruben Van Boxem <vanboxem.ruben>
Component: c++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED INVALID    
Severity: trivial    
Priority: P3    
Version: 4.6.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed:

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.