We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version:
Debian clang version 18.1.6 (++20240518023133+1118c2e05e67-1~exp1~20240518143227.130) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin
CMakeLists.txt
cmake_minimum_required(VERSION 3.10) project(test CXX) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) add_executable(test test.cpp)
test.cpp
#include <cstdlib> int main(int argc, char** argv) { char** p = nullptr; free(p); free((void*) p); free(static_cast<void*>(p)); }
Recipe:
cmake -B build -S . run-clang-tidy-18 -p build -checks="-*,bugprone-multi-level-implicit-pointer-conversion"
Output:
Enabled checks: bugprone-multi-level-implicit-pointer-conversion clang-tidy-18 -checks=-*,bugprone-multi-level-implicit-pointer-conversion -p=build /home/firma/devel/test/test.cpp /home/firma/devel/test/test.cpp:6:8: warning: multilevel pointer conversion from 'char **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] 6 | free(p); | ^ /home/firma/devel/test/test.cpp:8:16: warning: multilevel pointer conversion from 'char **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] 8 | free((void*) p); | ^ /home/firma/devel/test/test.cpp:10:27: warning: multilevel pointer conversion from 'char **' to 'void *', please use explicit cast [bugprone-multi-level-implicit-pointer-conversion] 10 | free(static_cast<void*>(p)); | ^ 3 warnings generated.
I don't understand why I get the warning here, in addition the suggested ways to "improve" the code using a cast don't work.
The text was updated successfully, but these errors were encountered:
This is problem with check. In your example you not removing implicit conversion, you just adding additional explicit one with void*.
In code like this:
#include <cstdlib> int main(int argc, char** argv) { char** p = nullptr; free(p); free((char*) p); free(reinterpret_cast<char*>(p)); }
issue isn't show up. Anyway check need to be relaxed to allow any explicit cast (to void* also). You can always also use NOLINT as temporary solution
Sorry, something went wrong.
[clang-tidy] Improve bugprone-multi-level-implicit-pointer-conversion
bdff94e
Ignore implicit pointer conversions that are part of a cast expression Closes llvm#93959
b55fb56
[clang-tidy] Improve bugprone-multi-level-implicit-pointer-conversion (…
0343388
…llvm#94524) Ignore implicit pointer conversions that are part of a cast expression Closes llvm#93959 Signed-off-by: Hafidz Muzakky <[email protected]>
@PiotrZSL Thanks for the fix.
PiotrZSL
Successfully merging a pull request may close this issue.
Version:
CMakeLists.txt
test.cpp
Recipe:
Output:
I don't understand why I get the warning here, in addition the suggested ways to "improve" the code using a cast don't work.
The text was updated successfully, but these errors were encountered: