Closed
Description
code example:
int main() {
void(*f)(void*);
}
the function pointer f
is not initialized, and clang-tidy suggest to add =nullptr
to initialize it. but clang-tidy add it to a wrong position:
code example from @HighCommander4
$ cat test.cpp
int main() {
void(*f)(void*);
}
$ clang-tidy --checks=cppcoreguidelines-init-variables --fix test.cpp
Running without flags.
1 warning generated.
test.cpp:2:11: warning: variable 'f' is not initialized [cppcoreguidelines-init-variables]
2 | void(*f)(void*);
| ^
| = nullptr
test.cpp:2:12: note: FIX-IT applied suggested code changes
2 | void(*f)(void*);
| ^
clang-tidy applied 1 of 1 suggested fixes.
$ cat test.cpp
int main() {
void(*f = nullptr)(void*);
}
expected behaviour:
int main() {
void(*f)(void*)=nullptr;
}