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

2026-04-29


3184. Pointer arithmetic with similar types

Section: 7.6.6  [expr.add]     Status: tentatively ready     Submitter: Jay Ghiron     Date: 2026-04-26

(From submission #892.)

Consider:

char**p;
int diff = p - (const char * const *)p;

This is ill-formed per 7.6.6 [expr.add] paragraph 2, but ought to be allowed, in harmony with 7.6.9 [expr.rel] paragraph 3, 7.6.10 [expr.eq] paragraph 3, and 7.6.16 [expr.cond] paragraph 4.

Proposed resolution (approved by CWG 2026-04-28):

Change in 7.6.6 [expr.add] paragraph 2 as follows:

For subtraction, one of the following shall hold: