[PATCH] D14096: [clang-tidy] add new check cppcoreguidelines-pro-type-cstyle-cast

Joerg Sonnenberger via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 1 11:31:11 PST 2015

On Tue, Oct 27, 2015 at 06:10:26PM +0000, Samuel Benzaquen via cfe-commits wrote:
> sbenza added a comment.
> In http://reviews.llvm.org/D14096#275902, @xazax.hun wrote:
> > There is already a similar check in the Google package. What are the differences between those two checks? What is the reason we can not just register that check into the core guidelines module?
> That other check discourages c-style cast in favor of C++ style casts, even if it is a reinterpret_cast. It simply replaces the cstyle cast with an equivalent C++ one. It is basically a stylistic check.
> This check will warn unsafe cstyle casts, while allowing safe ones like int->uint casts.
> This one is a safety related check.

Looking back to the discussion about the C++ style casts, this argument
makes no sense. For C++ code, reinterpret_cast is clearly preferable
over C-style casts for all but code size reasons. There seems to be no
consideration about "safe" uses with reinterpret_cast, so why should C-style casts
be different?


More information about the cfe-commits mailing list