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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 27 11:47:06 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:

Ah, right, yes... I wish we could explain that better in the brevity we have available here.  I kinda hate this is a warning with false-positives, but IMO the goal of trying to make this a deprecated cast is worth the effort.

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


More information about the cfe-commits mailing list