Skip to content

CWG3137 [expr.type] Composite pointer type requiring both qualification conversion and pointer-to-member conversion #822

@t3nsor

Description

@t3nsor

Full name of submitter: Brian Bi

Issue description: There is a gap in the specification of composite pointer type if both a pointer-to-member conversion and a qualification conversion are needed to achieve a common type. However, all implementations accept at least some such cases.

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

Suggested resolution: Edit [expr.type]/3.7 and add sub-bullets as follows. Note that the cross-reference to [dcl.init.ref] is struck because it already occurs in an earlier bullet.

  • if T1 is “pointer to member of C1 of type cv1 U1” and T2 is “pointer to member of C2 of type cv2 U2, for some non-function type U, where

    • U1 and U2 are similar object types and
    • C1 is reference-related to C2 or C2 is reference-related to C1 ([dcl.init.ref]),

    the qualification-combined type of T2 and T1 or the qualification-combined type of T1 and T2, respectively;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions