Issues 1:
int v = 10;
auto f = [v = v](){};
Consider the above code,some rules mentioned in the standard will work for it.
An init-capture behaves as if it declares and explicitly captures a variable of the form “auto init-capture ;” whose declarative region is the lambda-expression's compound-statement.
The quote means that auto v = v; would be declared in the lambda's compound-statement as if it like this:
//hypothetical code
int v = 10;
auto f = [](){
auto v = v; //the second `v` is the first `v` and will be initialized by an indetermined value.
};
So,For the hypothetical declaration auto v = v;,I think it will conflict with the following rules.
The point of declaration for a name is immediately after its complete declarator and before its initializer (if any) [ Example:
unsigned char x = 12;
{ unsigned char x = x; }
Here the second x is initialized with its own (indeterminate) value. — end example ]
Issue 2:
void func(int v){}
int v = 0;
func(v);
We know the initialization of the function's parameter will occur within the context of the calling function and it will be copy-initialization.We ignore the quotes in the standard,because they are too much.So the copy-initialization of parameter will appear in somewhere within the context of the calling function as if it likes such form:
//hypothetical code
int v = v; // initialization of a parameter that occured in somewhere within context of calling function
The same issue like issue 1,how to interpret these issues when the name of the declarator-id is the same as that of the id-expression that within a initializer when they occured in these hypothetical copy-initialization contexts.Does these hypothetical copy-initializations contradict with the rule [basic.scope.pdecl#1]
Question:
I wonder that Is the lookup for the id-expression within initializer preceded than the hypothetical declaration occures? why do I think so? because, as the opposite, During the usual declaration, the lookup for initializer occures after the declarator immediately complete, as said in [basic.scope.pdecl#1], It means the declarator-id would hide the id-expression that within the initializer if they are the same name.
Is there any quote in the standard interpret this?