Created on 2023-06-13.00:00:00 last changed 4 months ago
Proposed resolution (approved by CWG 2023-12-15):
Move a part of 7.6.1.5 [expr.ref] paragraph 1 to before paragraph 3 and edit as follows:
A postfix expression followed by a dot . or an arrow ->, optionally followed by the keyword template, and then followed by an id-expression, is a postfix expression.
The postfix expression before the dot or arrow is evaluated; [ Footnote: ... ] the result of that evaluation, together with the id-expression, determines the result of the entire postfix expression.[Note 1: If the keyword template is used, the following unqualified name is considered to refer to a template (13.3 [temp.names]). If a simple-template-id results and is followed by a ::, the id-expression is a qualified-id. —end note]For the first option (dot) the first expression shall be a glvalue. For the second option (arrow) the first expression shall be a prvalue having pointer type. The expression E1->E2 is converted to the equivalent form (*(E1)).E2; the remainder of 7.6.1.5 [expr.ref] will address only the first option (dot). [ Footnote: ... ]
The postfix expression before the dot is evaluated; [ Footnote: ... ] the result of that evaluation, together with the id-expression, determines the result of the entire postfix expression.
[Accepted as a DR at the March, 2024 meeting.]
Consider:
struct C { static int foo; }; C* c = nullptr;
The behavior of (*c).foo is clearly undefined per 7.6.1.5 [expr.ref] paragraph 1:
The postfix expression before the dot or arrow is evaluated ...
However, the treatment of c->foo is less clear, because the transformation to the form (*(E1)).E2 occurs later.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-07-20 13:52:34 | admin | set | status: dr -> drwp |
2024-04-05 21:43:46 | admin | set | status: ready -> dr |
2024-03-20 14:10:31 | admin | set | status: tentatively ready -> ready |
2023-12-16 00:18:01 | admin | set | status: open -> tentatively ready |
2023-06-13 18:44:12 | admin | set | messages: + msg7319 |
2023-06-13 00:00:00 | admin | create |