Title
Relational comparison of void* pointers
Status
c++23
Section
7.6.9 [expr.rel]
Submitter
Paul Keir

Created on 2020-06-15.00:00:00 last changed 16 months ago

Messages

Date: 2023-02-10.06:31:35

Proposed resolution (approved by CWG 2023-02-09):

Change in 7.6.9 [expr.rel] paragraph 5 as follows:

... Otherwise, the result of each of the operators is unspecified. [ Note: A relational operator applied to unequal function pointers or to unequal pointers to void yields an unspecified result. -- end note ]
Date: 2023-02-10.06:31:35

CWG 2022-11-11

Paper N3624 erroneously removed support for void* and function pointer relational comparisons. That ought to be restored.

Date: 2023-02-15.00:00:00

[Accepted as a DR at the February, 2023 meeting.]

Prior to the adoption of paper N3624 (resolving issue 1512), comparison of void* pointers was explicitly unspecified. The current wording of 7.6.9 [expr.rel], however, describes only comparison of “pointers to objects” (paragraphs 4 and 5), but a pointer to void is not a pointer to an object, only an object pointer type (as opposed to a function pointer type). Formally, that means that comparing void* pointers is undefined behavior, which seems undesirable.

As a related note, there is implementation divergence over whether relational comparisons of void* pointers are accepted in constant expressions (when the void* values are converted from pointers that would otherwise be comparable in constant expressions).

History
Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: dr -> open
2023-02-18 18:43:04adminsetstatus: ready -> dr
2023-02-10 23:01:52adminsetstatus: tentatively ready -> ready
2023-02-10 06:31:35adminsetmessages: + msg7185
2023-02-10 06:31:35adminsetstatus: review -> tentatively ready
2023-01-01 20:37:36adminsetstatus: drafting -> review
2022-11-20 07:54:16adminsetmessages: + msg7050
2022-11-20 07:54:16adminsetstatus: open -> drafting
2020-06-15 00:00:00admincreate