int func(int a) {
int PWL = PWL;
return PWL;
}
int main() {
return func(1);
}
Please see the godbolt: link https://godbolt.org/z/1c1Kax18n
int func(int a) {
int PWL = PWL;
return PWL;
}
int main() {
return func(1);
}
Please see the godbolt: link https://godbolt.org/z/1c1Kax18n
int PWL = PWL; does declare PWL. Though it is using the value of PWL before it is initialized, hence causes undefined behavior.
Sometimes such self referential initialization is desired, for example:
void* ptr = &ptr;
This is completely fine. Your case is not. Compilers should warn about it. See here for how it does not compile once you enable warnings: https://godbolt.org/z/vM7KMbfvv.