Skip to content

CWG2716 [class.conv.fct]/4 is normatively redundant #297

Closed
cplusplus/draft
#6328
@t3nsor

Description

@t3nsor

Full name of submitter: Brian Bi

Reference (section label): [class.conv.fct]

Issue description: [class.conv.fct]/4 reads:

A conversion function is never used to convert a (possibly cv-qualified) object to the (possibly cv-qualified) same object type (or a reference to it), to a (possibly cv-qualified) base class of that type (or a reference to it), or to cv void.

There is a footnote that explains the reasons: a derived to base conversion is a standard conversion (so a user-defined conversion function will never be considered for such a conversion) and the special rules for conversion to void do not involve any search for a conversion function. That means [class.conv.fct]/4 is normatively redundant and should be demoted to a note.

Suggested resolution: Edit [class.conv.fct]/4, integrating the footnote into the paragraph:

[Note -?-: A conversion function is never used to convert a (possibly cv-qualified) object to the (possibly cv-qualified) same object type (or a reference to it), to a (possibly cv-qualified) base class of that type (or a reference to it), or to cv void. These conversions are considered as standard conversions for the purposes of overload resolution ([over.best.ics], [over.ics.ref]) and therefore initialization ([dcl.init]) and explicit casts ([expr.static.cast]). A conversion to void does not invoke any conversion function ([expr.static.cast]). Even though never directly called to perform a conversion, such conversion functions can be declared and can potentially be reached through a call to a virtual conversion function in a base class. —end note]
[Example 1: [...]]

We might also want to consider clarifying what "never used to convert" means. NVC++ produces a warning that says "will not be called for implicit or explicit conversions", which I think is roughly what I would want to say here: "never used to implicitly or explicitly convert".

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