| Issue |
161978
|
| Summary |
clang-tidy: cppcoreguidelines-init-variables does not work for a function pointer that has two or more parameters
|
| Labels |
clang-tidy
|
| Assignees |
|
| Reporter |
e-kwsm
|
```cpp
int main() {
bool (*fp1)(int);
bool (*fp2)(int, int);
}
```
```console
$ clang-tidy '--checks=-*,cppcoreguidelines-init-variables' --fix a.cpp
/tmp/a.cpp:2:10: warning: variable 'fp1' is not initialized [cppcoreguidelines-init-variables]
2 | bool (*fp1)(int);
| ^
| = nullptr
/tmp/a.cpp:2:19: note: FIX-IT applied suggested code changes
2 | bool (*fp1)(int);
| ^
/tmp/a.cpp:3:10: warning: variable 'fp2' is not initialized [cppcoreguidelines-init-variables]
3 | bool (*fp2)(int, int);
| ^
| = nullptr
/tmp/a.cpp:3:18: note: FIX-IT applied suggested code changes
3 | bool (*fp2)(int, int);
| ^
clang-tidy applied 2 of 2 suggested fixes.
```
gives
```cpp
int main() {
bool (*fp1)(int) = nullptr;
bool (*fp2)(int = nullptr, int);
}
```
<https://godbolt.org/z/hTjdh79K5>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs