Skip to content

CWG2958 [over.ics.rank] Incorrect example of overload resolution with qualification conversion #639

Description

Full name of submitter: Vincent X

Reference: [over.ics.rank]

Issue description: In Example 5:

int g(const int*);                 // (1)
int g(const volatile int* const&); // (2)
int* p;
int k = g(p);                   // calls g(const int*)

(1) involves an lvalue-to-rvalue conversion followed by a qualification conversion, whereas (2) only requires a qualification conversion. Since [over.ics.rank]/3.2.5 assumes:

S1 and S2 differ only in their qualification conversion ([conv.qual]) [...]

This call should be ambiguous. This issue was initially discussed on Slack. The above example was introduced in CWG2803.

Suggested resolution: Modify the example as follows:

int g(const int* const&); 
int g(const volatile int* const&);
int* p;
int k = g(p);                   // calls g(const int* const&)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions