Created on 2021-12-10.00:00:00 last changed 12 months ago
CWG 2023-11-09
Progress of this issue is blocked on issue 2554.
Proposed resolution (approved by CWG 2023-07-14):
Change in 9.3.4.6 [dcl.fct] paragraph 6 as follows:
A member-declarator with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared staticor virtual.
Change in 9.3.4.6 [dcl.fct] paragraph 7 as follows:
... An implicit object member function is a non-static member function without an explicit object parameter. [ Note: An explicit object member function cannot be virtual (11.7.3 [class.virtual]). -- end note ]
Change in 11.4.11 [class.free] paragraph 1 as follows:
Any allocation function for a class T is a static member (even if not explicitly declared static); it shall not have an explicit object parameter.
Change in 11.4.11 [class.free] paragraph 3 as follows:
Any deallocation function for a class T is a static member (even if not explicitly declared static); it shall not have an explicit object parameter.
Change in 11.4.11 [class.free] paragraph 4 as follows:
[ Note: Since member allocation and deallocation functions are static they cannot be virtual. -- end note ]
Add a new paragraph before 11.7.3 [class.virtual] paragraph 7 as follows:
A virtual function shall not be an explicit object member function (9.3.4.6 [dcl.fct]).
[ Example:
struct B { virtual void g(); // #1 }; struct D : B { virtual void f(this D&); // error: explicit object member function cannot be virtual void g(this D&); // error: overrides #1; explicit object member function cannot be virtual };-- end example]
The ref-qualifier, or lack thereof, ...
Proposed resolution (approved by CWG 2023-06-15) [SUPERSEDED]:
Change in 9.3.4.6 [dcl.fct] paragraph 6 as follows:
A member-declarator with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared staticor virtual.
Change in 9.3.4.6 [dcl.fct] paragraph 7 as follows:
... An implicit object member function is a non-static member function without an explicit object parameter. [ Note: An explicit object member function cannot be virtual (11.7.3 [class.virtual]). -- end note ]
Add a new paragraph before 11.7.3 [class.virtual] paragraph 7 as follows:
A virtual function shall not be an explicit object member function (9.3.4.6 [dcl.fct]).
[ Example:
struct B { virtual void g(); // #1 }; struct D : B { virtual void f(this D&); // error: explicit object member function cannot be virtual void g(this D&); // error: overrides #1; explicit object member function cannot be virtual };-- end example]
The ref-qualifier, or lack thereof, ...
Subclause 9.3.4.6 [dcl.fct] paragraph 6 specifies
A member-declarator with an explicit-object-parameter-declaration shall not include a ref-qualifier or a cv-qualifier-seq and shall not be declared static or virtual.
This does not address the situation when an explicit object member function becomes implicitly virtual by overriding an implicit object member function. That should be prevented.
This also does not address class-specific allocation and deallocation functions, which are implicitly static.
History | |||
---|---|---|---|
Date | User | Action | Args |
2023-11-10 06:40:38 | admin | set | messages: + msg7509 |
2023-11-10 06:40:38 | admin | set | status: ready -> review |
2023-07-14 21:37:18 | admin | set | status: review -> ready |
2023-06-22 21:39:53 | admin | set | messages: + msg7339 |
2023-06-22 21:39:53 | admin | set | status: drafting -> review |
2023-06-16 16:50:06 | admin | set | status: ready -> drafting |
2023-06-15 09:15:39 | admin | set | status: open -> ready |
2022-03-23 23:03:41 | admin | set | messages: + msg6770 |
2021-12-10 00:00:00 | admin | create |