[cfe-commits] [PATCH] PR13824 warn if reinterpret_cast used for up/downcast

Dmitri Gribenko gribozavr at gmail.com
Wed Jan 23 14:53:38 PST 2013


On Thu, Jan 24, 2013 at 12:40 AM, Alexander Zinenko <ftynse at gmail.com> wrote:
> On 23 January 2013 23:52, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>> I think it is sensible to leave the warning on by default.  The
>> purpose of a separate flag is to turn off the (possibly) noisy case
>> separately.
>
> Having it on by default, clang fails to pass these tests:
>     Clang :: Analysis/inlining/dyn-dispatch-bifurcate.cpp
>     Clang :: SemaCXX/address-space-conversion.cpp
> That's why the noisy version was disabled by default even in the first
> version.

Well, compiler tests do weird things, so this is not representative.

I think the only reasonable false positive source for zero adjustment
case is templates:

template<typename T, typename U>
void foo(T *t) {
  ... reinterpret_cast<U*>(t);
}

Where T and U have some subtyping relationship.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-commits mailing list