Title
Dangling references
Status
dr
Section
7.2.2 [expr.type]
Submitter
Brian Bi

Created on 2024-09-04.00:00:00 last changed 4 days ago

Messages

Date: 2024-11-09.00:21:39

Proposed resolution (approved by CWG 2024-11-08):

  1. Change in 6.8.2 [basic.fundamental] paragraph 4 as follows:

    A pointer value P is valid in the context of an evaluation E if P is a pointer to function or a null pointer value, or if it is a pointer to or past the end of an object O and E happens before the end of the duration of the region of storage for O. If a pointer value P is used in an evaluation E and P is not valid in the context of E, then ...
  2. Change in 7.2.2 [expr.type] paragraph 1 as follows:

    If an expression initially has the type “reference to T” (9.3.4.3 [dcl.ref], 9.4.4 [dcl.init.ref]), the type is adjusted to T prior to any further analysis; the value category of the expression is not altered. The expression designates Let X be the object or function denoted by the reference, and the expression is an lvalue or an xvalue, depending on the expression. If a pointer to X would be valid in the context of the evalution of the expression (6.8.2 [basic.fundamental]), the result designates X; otherwise, the behavior is undefined.
Date: 2024-11-15.00:00:00

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

Issue 453 clarified that there are no empty lvalues, and undefined behavior ensues when trying to create one. However, the wording now does not specify the behavior of dangling references, where the storage of the referenced object has gone away.

History
Date User Action Args
2024-12-17 09:54:02adminsetstatus: ready -> dr
2024-12-06 09:40:31adminsetstatus: tentatively ready -> ready
2024-11-09 00:21:39adminsetmessages: + msg7885
2024-11-09 00:21:39adminsetstatus: open -> tentatively ready
2024-09-04 00:00:00admincreate