Created on 2024-03-14.00:00:00 last changed 1 month ago
Suggested resolution:
Change in 7.5.2 [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).
Alternative possible resolution:
Change in 7.5.2 [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).
(From submission #515.)
Consider:
struct A { static void f() { struct B { void *g() { return this; } }; } };
According to 7.5.2 [expr.prim.this] paragraph 3, this example is ill-formed, because this "appears within" the declaration of a static member function.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-03-17 06:36:43 | admin | set | messages: + msg7636 |
2024-03-14 00:00:00 | admin | create |