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

2024-12-19


2786. Comparing pointers to complete objects

Section: 7.6.10  [expr.eq]     Status: open     Submitter: Alisdair Meredith     Date: 2023-08-23

Subclause 7.6.10 [expr.eq] bullet 3.1 specifies:

This phrasing does not properly handle the case where addresses of subobjects are compared, yet those subobjects happen to have the same address as their respective complete objects.

The rule in question was introduced by issue 1652 for purposes of constant evaluation: comparing a pointer to an object X with a pointer past the end of another object Y ought not to be possible during contant evaluation. However, that issue resolution also caused a change to runtime behavior, departing from the prior "address comparison" model. It turns out that implementations nowadays rely on that rule for optimization purposes (see the reflector discussion).

Possible resolution:

Change in 7.6.10 [expr.eq] bullet 3.1 as follows: