Issue |
150397
|
Summary |
[clang-tidy] Invalid fixit from cppcoreguidelines-init-variables in the presence of goto
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
chrchr-github
|
~~~c++
void g(int);
int f(int i) {
if (i == -1)
goto end;
int x;
if (i > 1)
x = 1;
else
x = 0;
g(x);
end:
return 0;
}
~~~
~~~
<source>:5:9: warning: variable 'x' is not initialized [cppcoreguidelines-init-variables]
5 | int x;
| ^
| = 0
~~~
Applying the fix results in
~~~
<source>:4:9: error: cannot jump from this goto statement to its label [clang-diagnostic-error]
4 | goto end;
| ^
<source>:5:9: note: jump bypasses variable initialization
5 | int x{};
| ^
~~~
https://godbolt.org/z/j43cdjYvo
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs