I had this lambda somewhere in my code:
[](bool a, bool=true){ return !a;} }
and GCC 4.6 "complained" with this warning:
warning: default argument specified for lambda parameter [-pedantic]
Which is mightily unhelpful when you don't know why this is "bad". I consulted the FDIS n3290 and didn't find anything in 5.1.2 Lambda Expressions
with regards to default arguments and a lambda.
UPDATE: I filed a bug report here.
UPDATE2: OK, from now on I'm using -pedantic-errors
. -pedantic
only emits warnings, not errors.
Since C++14 it is allowed. It was found to be a defect long time ago: Default arguments for lambdas, and also Default arguments in lambda-expressions.
It makes no sense to have a default argument in a lambda function -- how could it ever be used? On the other hand, it does no harm, so why not allow it, after emitting a warning?
Section 5.1.2 paragraph 5 specifically says that you can not have default values for the parameters.