llvm / llvm/llvm-project

[clang-tidy] Warn for integer-to-pointer cast with size mismatch

Open
#184,797 4 comments 0 reactions 0 assignees View on GitHub
check-request clang-tidy
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

~~~c++
#include
#include

void f(std::ofstream& fout, std::uint32_t u) {
fout.write(reinterpret_cast(u), sizeof(u)); // cannot be a pointer
}
~~~
https://godbolt.org/z/EY85odK3E
Not sure if this should be a diagnostic or a clang-tidy check. `cppcoreguidelines-pro-type-reinterpret-cast` and `performance-no-int-to-ptr` seem too unspecific.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.