Skip to content

[class.copy.assign]/7.4 CWG 1499: misses the unsuccessful overload resolution case #2179

Closed
@languagelawyer

Description

@languagelawyer

[class.copy.assign]/7 says:

A defaulted copy/move assignment operator for class X is defined as deleted if X has:

(7.4) — a direct non-static data member of class type M (or array thereof) or a direct base class M that cannot be copied/moved because overload resolution, as applied to find M's corresponding assignment operator, results in an ambiguity or a function that is deleted or inaccessible from the defaulted assignment operator.

For the code

struct M {};

struct X {
    const M m{};
};

(I assume) the intent is that the implicit copy assignment operator for X shall be deleted. But:

  1. M's assignment operator is accessible and not deleted. "inaccessible" ­— is about access control, right?
  2. Overload resolution is not ambiguous, because the set of viable functions chosen by [over.match.viable] is empty: there is no implicit conversion from const M implied object argument to M& implicit object parameter of M's implicitly-declared copy assignment operator.
    And If the set of candidate functions is empty, overload resolution is unsuccessful.
    unsuccessful ≠ ambiguous. There is no ambiguity when there is nothing to select from.

Should only this paragraph be fixed or the fix for [over.match] is also required to say explicitly that unsuccessful overload resolution means ill-formed program (or vice versa), I don't know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions