This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 110b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2023-01-15


1504. Pointer arithmetic after derived-base conversion

Section: 7.6.6  [expr.add]     Status: CD3     Submitter: Loïc Joly     Date: 2012-05-20

[Moved to DR at the April, 2013 meeting.]

The current wording is not sufficiently clear that a pointer to a base class subobject of an array element cannot be used in pointer arithmetic.

Proposed resolution (October, 2012):

Add the following as a new paragraph before 7.6.6 [expr.add] paragraph 7:

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]

If the value 0 is added to or subtracted...