[clang] [Clang] Diagnose down casting static_cast (PR #117914)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 27 11:26:19 PST 2024


================
@@ -7982,6 +7982,9 @@ def err_bad_reinterpret_cast_reference : Error<
 def warn_undefined_reinterpret_cast : Warning<
   "reinterpret_cast from %0 to %1 has undefined behavior">,
   InGroup<UndefinedReinterpretCast>, DefaultIgnore;
+def warn_static_downcast : Warning<
+  "static downcast from %0 to %1 is potentially dangerous%select{|; did you mean 'dynamic_cast'?}2">,
----------------
erichkeane wrote:

I think it is more than 'potentially dangerous', yes?  Perhaps also we should mention the polymorphic-ness of the types as to why it is dangerous.

https://github.com/llvm/llvm-project/pull/117914


More information about the cfe-commits mailing list