Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
t3nsor opened this issue Apr 11, 2023 · 1 comment · Fixed by cplusplus/draft#6328
Closed

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

t3nsor opened this issue Apr 11, 2023 · 1 comment · Fixed by cplusplus/draft#6328

Comments

@t3nsor
Copy link

t3nsor commented Apr 11, 2023

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".

@jensmaurer
Copy link
Member

jensmaurer commented Apr 11, 2023

CWG2716

"used" is too generic a word; "invoked" is better

@jensmaurer jensmaurer changed the title [class.conv.fct]/4 is normatively redundant CWG2716 [class.conv.fct]/4 is normatively redundant Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants