[clang-tidy] Warn for integer-to-pointer cast with size mismatch
Open
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
Assessment
This issue has not been assessed yet.