Title
Composite pointer type with qualification and pointer-to-member conversions
Status
open
Section
7.2.2 [expr.type]
Submitter
Brian Bi

Created on 2025-11-25.00:00:00 last changed 1 week ago

Messages

Date: 2025-11-29.16:24:57

Possible resolution:

Change in 7.2.2 [expr.type] bullet 3.7 and 3.8 as follows:

  • ...
  • if T1 is “pointer to member of C1 of type cv1 U U1” and T2 is “pointer to member of C2 of type cv2 U U2”, for some non-function type U similar types U1 and U2, where C1 is reference-related to C2 or C2 is reference-related to C1 (9.5.4 [dcl.init.ref]), the qualification-combined type of T2 and T1 or the qualification-combined type of T1 and T2, respectively;
  • if T1 and T2 are similar types (7.3.6 [conv.qual]), the qualification-combined type of T1 and T2;
  • ...
Date: 2025-11-25.00:00:00

(From submission #822.)

There is a specification gap for "composite pointer type" in the case where both a qualification conversion and a pointer-to-member conversion is needed to achieve a common type. For example:

  using P = int*;
  using CP = const int* const;
  struct B {
    P a;
  };
  struct D : B {};

  constexpr P (B::*bnc) = &B::a;
  constexpr CP (B::*bc) = &B::a;
  constexpr P (D::*dnc) = &B::a;
  constexpr CP (D::*dc) = dnc;     // work around GCC bug

  static_assert(bnc == dc);
  static_assert(bc == dnc);        // EDG rejects
History
Date User Action Args
2025-11-29 09:45:44adminsetmessages: + msg8423
2025-11-25 00:00:00admincreate