[PATCH] D102689: [C++] Ignore top-level qualifiers in casts

Ole Strohm via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 9 04:38:59 PDT 2021


olestrohm added inline comments.


================
Comment at: clang/test/SemaCXX/warn-reinterpret-base-class.cpp:301
 
-  // expected-warning at +2 {{'reinterpret_cast' to class 'L' (aka 'const F *volatile') from its base at non-zero offset 'E *' behaves differently from 'static_cast'}}
+  // expected-warning at +2 {{'reinterpret_cast' to class 'K' (aka 'const F *') from its base at non-zero offset 'E *' behaves differently from 'static_cast'}}
   // expected-note at +1 {{use 'static_cast' to adjust the pointer correctly while downcasting}}
----------------
Anastasia wrote:
> I wonder if there is a way to track the original type for the diagnostic? Or maybe it is intuitive enough considering the quoted spec wording...
This actually already happens with the source type too.
const short s = 0;
reinterpret_cast<int>(s);

gives the error "reinterpret_cast from 'short' to 'int' is not allowed", so while this is definitely worse, it's a general problem with reinterpret_cast.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102689/new/

https://reviews.llvm.org/D102689



More information about the cfe-commits mailing list