================
@@ -19,20 +19,35 @@ Example:
.. code-block:: c++
struct Base {
- virtual void ~Base();
+ virtual ~Base();
+ int i;
};
-
+
struct Derived : public Base {};
-
- void foo() {
- Base *b = new Derived[10];
-
+
+ // Function that takes a pointer and performs pointer arithmetic
+ void foo(Base* b) {
b += 1;
// warning: pointer arithmetic on class that declares a virtual function
can
// result in undefined behavior if the dynamic type differs from the
// pointer type
+ }
+
+ void bar() {
+ Derived d[10]; // Array of derived objects
+ foo(d); // Passing Derived pointer to foo(), which performs
arithmetic
+ }
----------------
nicovank wrote:
```suggestion
```
This is not showcasing a warning (or no-warning).
https://github.com/llvm/llvm-project/pull/108324
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits