tmp/tmpn7_w3zd0/{from.md → to.md}
RENAMED
|
@@ -14,10 +14,12 @@ either
|
|
| 14 |
the set of potential results of `e`, and `ex` names a variable `x`
|
| 15 |
that is not odr-used by `ex` ([[basic.def.odr]]),
|
| 16 |
|
| 17 |
the value contained in the referenced object is not accessed.
|
| 18 |
|
|
|
|
|
|
|
| 19 |
``` cpp
|
| 20 |
struct S { int n; };
|
| 21 |
auto f() {
|
| 22 |
S x { 1 };
|
| 23 |
constexpr S y { 2 };
|
|
@@ -26,21 +28,26 @@ auto f() {
|
|
| 26 |
auto g = f();
|
| 27 |
int m = g(false); // undefined behavior due to access of x.n outside its lifetime
|
| 28 |
int n = g(true); // OK, does not access y.n
|
| 29 |
```
|
| 30 |
|
| 31 |
-
|
| 32 |
-
to the following rules:
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
- Otherwise, if the object to which the glvalue refers contains an
|
| 40 |
invalid pointer value ([[basic.stc.dynamic.deallocation]],
|
| 41 |
-
[[basic.stc.dynamic.safety]]), the behavior is
|
|
|
|
| 42 |
- Otherwise, the value contained in the object indicated by the glvalue
|
| 43 |
is the prvalue result.
|
| 44 |
|
| 45 |
-
See also [[basic.lval]].
|
| 46 |
|
|
|
|
| 14 |
the set of potential results of `e`, and `ex` names a variable `x`
|
| 15 |
that is not odr-used by `ex` ([[basic.def.odr]]),
|
| 16 |
|
| 17 |
the value contained in the referenced object is not accessed.
|
| 18 |
|
| 19 |
+
[*Example 1*:
|
| 20 |
+
|
| 21 |
``` cpp
|
| 22 |
struct S { int n; };
|
| 23 |
auto f() {
|
| 24 |
S x { 1 };
|
| 25 |
constexpr S y { 2 };
|
|
|
|
| 28 |
auto g = f();
|
| 29 |
int m = g(false); // undefined behavior due to access of x.n outside its lifetime
|
| 30 |
int n = g(true); // OK, does not access y.n
|
| 31 |
```
|
| 32 |
|
| 33 |
+
— *end example*]
|
|
|
|
| 34 |
|
| 35 |
+
The result of the conversion is determined according to the following
|
| 36 |
+
rules:
|
| 37 |
+
|
| 38 |
+
- If `T` is cv `std::nullptr_t`, the result is a null pointer constant (
|
| 39 |
+
[[conv.ptr]]). \[*Note 1*: Since no value is fetched from memory,
|
| 40 |
+
there is no side effect for a volatile access ([[intro.execution]]),
|
| 41 |
+
and an inactive member of a union ([[class.union]]) may be
|
| 42 |
+
accessed. — *end note*]
|
| 43 |
+
- Otherwise, if `T` has a class type, the conversion copy-initializes
|
| 44 |
+
the result object from the glvalue.
|
| 45 |
- Otherwise, if the object to which the glvalue refers contains an
|
| 46 |
invalid pointer value ([[basic.stc.dynamic.deallocation]],
|
| 47 |
+
[[basic.stc.dynamic.safety]]), the behavior is
|
| 48 |
+
*implementation-defined*.
|
| 49 |
- Otherwise, the value contained in the object indicated by the glvalue
|
| 50 |
is the prvalue result.
|
| 51 |
|
| 52 |
+
[*Note 2*: See also [[basic.lval]]. — *end note*]
|
| 53 |
|