Question
Function default argument value depending on argument name in C++
If one defines a new variable in C++, then the name of the variable can be used in the initialization expression, for example:
int x = sizeof(x);
And what about default value of a function argument? Is it allowed there to reference the argument by its name? For example:
void f(int y = sizeof(y)) {}
This function is accepted in Clang, but rejected in GCC with the error:
'y' was not declared in this scope
Demo: https://gcc.godbolt.org/z/YsvYnhjTb
Which compiler is right here?