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&)

Activity

  1. jensmaurer commented on Nov 10, 2024

    @jensmaurer
    Member

    I think fixing the example is not what we want. Instead, we want the normative words to reflect the intent expressed in the example.

  2. t3nsor commented on Nov 11, 2024

    @t3nsor

    I think we could just borrow the "excluding any lvalue transformation" wording from p3.2.1.

  3. jensmaurer commented on Nov 11, 2024

    @jensmaurer
    Member
  4. changed the title [-][over.ics.rank] Incorrect Example of Overload Resolution with Qualification Conversion[/-] [+]CWG2958 [over.ics.rank] Incorrect Example of Overload Resolution with Qualification Conversion[/+] on Nov 11, 2024
  5. ghost changed the title [-]CWG2958 [over.ics.rank] Incorrect Example of Overload Resolution with Qualification Conversion[/-] [+]CWG2958 [over.ics.rank] Incorrect example of overload resolution with qualification conversion[/+] on Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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