Movatterモバイル変換


[0]ホーム

URL:


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

2025-11-07


2526. Relational comparison ofvoid* pointers

Section:7.6.9  [expr.rel]    Status:C++23    Submitter:Paul Keir    Date:2020-06-15

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

Prior to the adoption of paper N3624 (resolvingissue 1512), comparison ofvoid* pointers was explicitly unspecified. Thecurrent wording of 7.6.9 [expr.rel], however,describes only comparison of “pointers toobjects” (paragraphs 4 and 5), but a pointertovoid is not a pointer to an object, only anobject pointer type (as opposed to a function pointer type).Formally, that means that comparingvoid* pointersis undefined behavior, which seems undesirable.

As a related note, there is implementation divergenceover whether relational comparisons ofvoid* pointersare accepted in constant expressions (when thevoid*values are converted from pointers that would otherwise becomparable in constant expressions).

CWG 2022-11-11

Paper N3624 erroneously removed support forvoid* andfunction pointer relational comparisons. That ought to be restored.

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 functionpointers or to unequal pointers tovoid yields an unspecifiedresult. -- end note ]



[8]ページ先頭

©2009-2025 Movatter.jp