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

John McCall rjmccall at apple.com
Wed Mar 20 17:18:36 PDT 2013


On Mar 20, 2013, at 5:00 PM, Alexander Zinenko <ftynse at gmail.com> wrote:
> I agree with your point about instantiation. My example is just another case that should not be checked. And it happens that this is getting done by the same condition "has no complete definition". I added a comment covering all of this anyways. 

Please add a test case where code tries to reinterpret-cast an incompletely-defined struct.  (We just want to ensure that we don't crash for this.)  This means putting a reinterpret_cast into a type expression in class context (not within a member function), e.g.

  struct A {
    decltype(reinterpret_cast<A*>((B*) 0)) x;
  };

With that, this patch looks fine;  feel free to commit.

John.



More information about the cfe-commits mailing list