Open daljit46 opened 1 week ago
:+1: Does clang-tidy
catch these / can it autofix?
Clang-tidy does seem to have a check for this: cppcoreguidelines-pro-type-cstyle-cast, but in my experience it doesn't seem to provide a fixit (even though it should) and it also doesn't diagnose the issue properly in the majority of cases. Although, I probably should test this on various platforms to check whether it's an issue with my configuration.
There are several places in our codebase where we are relying on C-style casts instead of using C++ casts. While it's true that writing something like
float(value)
is shorter and arguably more readable than something likestatic_cast<float>(value)
, C-style casts are inherently a worse choice. In particular, there are three benefits of using C++ style casts: