-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Open
Labels
Description
Consider:
void f2(int i) {}
void f(int k) {
int i;
_Defer f2(i);
if (k > 1) return;
i = 1;
if (k > 2) return;
i = 2;
}
int main() {}We have two warnings:
<source>:4:15: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
4 | _Defer f2(i);
| ^
<source>:3:10: note: initialize the variable 'i' to silence this warning
3 | int i;
| ^
| = 0
1 warning generated.
ASM generation compiler returned: 0
<source>:4:15: warning: variable 'i' is uninitialized when used here [-Wuninitialized]
4 | _Defer f2(i);
| ^
<source>:3:10: note: initialize the variable 'i' to silence this warning
3 | int i;
| ^
| = 0
1 warning generated.
Execution build compiler returned: 0
Program returned: 0
https://godbolt.org/z/3sz7cT8Wv
But the uninitialized warning should be only at if (k > 1) return;.
Also, any warning captured by flow analysis should print the line were defer is executed.