Title
An implicit definition does not redeclare a function
Status
drwp
Section
9.5.2 [dcl.fct.def.default]
Submitter
Brian Bi

Created on 2023-09-27.00:00:00 last changed 5 months ago

Messages

Date: 2024-03-20.05:56:01

Proposed resolution (approved by CWG 2024-03-20):

Insert a paragraph break before the quoted section and change in 9.5.2 [dcl.fct.def.default] paragraph 5 as follows:

... A function is user-provided if it is user-declared and not explicitly defaulted or deleted on its first declaration. A user-provided explicitly-defaulted function (i.e., explicitly defaulted after its first declaration) is implicitly defined at the point where it is explicitly defaulted; if such a function is implicitly defined as deleted, the program is ill-formed. [Note 1: Declaring a function as defaulted after its first declaration can provide efficient execution and concise definition while enabling a stable binary interface to an evolving code base. —end note] A non-user-provided defaulted function (i.e., implicitly declared or explicitly defaulted in the class) that is not defined as deleted is implicitly defined when it is odr-used (6.3 [basic.def.odr]) or needed for constant evaluation (7.7 [expr.const]). [Note 1: Declaring a function as defaulted after its first declaration can provide efficient execution and concise definition while enabling a stable binary interface to an evolving code base. —end note] [ Note: The implicit definition of a non-user-provided defaulted function does not bind any names. -- end note ]
Date: 2024-03-15.00:00:00

[Accepted as a DR at the March, 2024 meeting.]

Subclause 9.5.2 [dcl.fct.def.default] paragraph 5 specifies:

... A user-provided explicitly-defaulted function (i.e., explicitly defaulted after its first declaration) is implicitly defined at the point where it is explicitly defaulted; if such a function is implicitly defined as deleted, the program is ill-formed. A non-user-provided defaulted function (i.e., implicitly declared or explicitly defaulted in the class) that is not defined as deleted is implicitly defined when it is odr-used (6.3 [basic.def.odr]) or needed for constant evaluation (7.7 [expr.const]).

In the first case, there is a second point of declaration for the function, wherever the user wrote the definition. In contrast, there is no redeclaration for the second case, where the function is not user-provided. A note would clarify.

History
Date User Action Args
2024-07-20 13:52:34adminsetstatus: dr -> drwp
2024-04-05 21:43:46adminsetstatus: ready -> dr
2024-03-20 05:59:16adminsetstatus: tentatively ready -> ready
2023-12-02 13:35:39adminsetstatus: open -> tentatively ready
2023-10-18 19:15:28adminsetmessages: + msg7461
2023-09-27 00:00:00admincreate