The section on lambda captures ([expr.prim.lambda.capture]/5) states that
If an identifier in a simple-capture appears as the declarator-id of a parameter of the lambda-declarator's parameter-declaration-clause, the program is ill-formed.
Consider the follow example:
#include <iostream>
int main ()
{
auto foo = 1234;
auto bar = [foo](int foo) { std::cout << foo << '\n'; };
bar(4321);
}
The latest GCC version (8.2.0 - released on July 26, 2018) has no diagnostic for this. Neither does latest Clang version (7.0.0 - released on Sep 19, 2018).
Should there be a diagnostic (error/warning) from these compilers (as mentioned in the reference) along the lines of:
// parameter and simple-capture have the same name
Godbolt Demo here