Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The definition of pointer arithmetic from the C++ Standard, [expr.add], paragraph 7 [ISO/IEC 14882-2014], states:

For addition or subtraction, if the expressions P or Q have type “pointer to cv T”, where T is different from the cv-unqualified array element type, the behavior is undefined. [Note: In particular, a pointer to a base class cannot be used for pointer arithmetic when the array contains objects of a derived class type. —end note]

...

Bibliography

[ISO/IEC 14882-2014]

Subclause 5.7, "Additive Operators"
Subclause 5.2.1, "Subscripting" 

[Lockheed Martin 05]AV Rule 96, Arrays shall not be treated polymorphically
[Meyers 06]Item 3, "Never Treat Arrays Polymorphically"
[Stroustrup 06]"What's Wrong with Arrays?"
[Sutter 04]Item 100, "Don't Treat Arrays Polymorphically"

...