[clang-tools-extra] [clang-tidy] Add `bugprone-pointer-arithmetic-on-polymorphic-object` check (PR #91951)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 10 12:48:58 PDT 2024


================
@@ -0,0 +1,61 @@
+.. title:: clang-tidy - bugprone-pointer-arithmetic-on-polymorphic-object
+
+bugprone-pointer-arithmetic-on-polymorphic-object
+=================================================
+
+Finds pointer arithmetic performed on classes that declare a virtual function.
+
+Pointer arithmetic on polymorphic objects where the pointer's static type is 
+different from its dynamic type is undefined behavior, as the two types can
+have different sizes.
----------------
PiotrZSL wrote:

"as the two types can have different sizes."
this apply also to non polymorphic classes.

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


More information about the cfe-commits mailing list