Created on 2024-03-14.00:00:00 last changed 4 months ago
Proposed resolution (approved by CWG 2024-05-17):
Change in 7.5.3 [expr.prim.this] paragraph 3 as follows:
If a declaration declares a member function or member function template of a class X, the expression this is a prvalue of type “pointer to cv-qualifier-seq X” wherever X is the current class between the optional cv-qualifier-seq and the end of the function-definition, member-declarator, or declarator. It shall not appear within the declaration ofeithera staticmember functionoranexplicit object member function of the current class (although its type and value category are defined within such member functions as they are within an implicit object member function).
CWG 2024-05-03
CWG preferred a smaller surgery to avoid the English parsing issue.
Suggested resolution [SUPERSEDED]:
Change in 7.5.3 [expr.prim.this] paragraph 3 as follows:
If a declaration declares a member function or member function template of a class X, the expression this is a prvalue of type “pointer to cv-qualifier-seq X” wherever X is the current class between the optional cv-qualifier-seq and the end of the function-definition, member-declarator , or declarator.It shall not appear within theThe declarationof eitherthat determines the type of this shall declare neither a static member functionornor an explicit object member function of the current class (although its type and value category are defined within such member functions as they are within an implicit object member function).
[Accepted as a DR at the June, 2024 meeting.]
(From submission #515.)
Consider:
struct A { static void f() { struct B { void *g() { return this; } }; } };
According to 7.5.3 [expr.prim.this] paragraph 3, this example is ill-formed, because this "appears within" the declaration of a static member function. The qualification "of the current class" can be read as attaching to explicit object member functions only.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-07-20 13:52:34 | admin | set | status: ready -> dr |
2024-06-27 04:25:11 | admin | set | status: tentatively ready -> ready |
2024-05-17 22:24:28 | admin | set | messages: + msg7700 |
2024-05-17 22:24:28 | admin | set | status: review -> tentatively ready |
2024-05-13 09:44:12 | admin | set | messages: + msg7696 |
2024-05-13 09:44:12 | admin | set | status: open -> review |
2024-03-17 06:36:43 | admin | set | messages: + msg7636 |
2024-03-14 00:00:00 | admin | create |