Pointer comparison vs qualification conversions
7.6.9 [expr.rel]
Steve Clamage

Created on 2012-06-22.00:00:00 last changed 108 months ago


Date: 2013-04-15.00:00:00

[Moved to DR status at the April, 2013 meeting as paper N3624.]

Date: 2012-11-15.00:00:00

Proposed resolution (November, 2012):

The proposed wording is found in document N3478.

(This resolution also resolves issue 583.)

Date: 2012-06-22.00:00:00

According to 7.6.9 [expr.rel] paragraph 2, describing pointer comparisons,

Pointer conversions (7.3.12 [conv.ptr]) and qualification conversions (7.3.6 [conv.qual]) are performed on pointer operands (or on a pointer operand and a null pointer constant, or on two null pointer constants, at least one of which is non-integral) to bring them to their composite pointer type.

This would appear to make the following example ill-formed,

  bool foo(int** x, const int** y) {
     return x < y;  // valid ?

because int** cannot be converted to const int**, according to the rules of 7.3.6 [conv.qual] paragraph 4. This seems too strict for pointer comparison, and current implementations accept the example.

Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2013-10-14 00:00:00adminsetstatus: dr -> drwp
2013-05-03 00:00:00adminsetmessages: + msg4388
2013-05-03 00:00:00adminsetstatus: review -> dr
2012-11-03 00:00:00adminsetmessages: + msg4083
2012-11-03 00:00:00adminsetstatus: open -> review
2012-06-22 00:00:00admincreate