Date: Thu, 16 Apr 2020 01:49:47 +0900
On Thu, Apr 16, 2020 at 12:36 AM Tadeus Prastowo
<tadeus.prastowo_at_[hidden]> wrote:
> Sentence-X is futher elaborated in Sentence-Y where Sentence-Y
> provides a forward reference, while the pointer defined in Sentence-X
> is further elaborated in Sentence-A, -B, and -C where Sentence-A, -B,
> and -C provide details and Sentence-C is the one that starts with "The
> program has undefined behavior if:" and continues to [basic.life]6.1
> up to 6.5.
Thank you for explaining so politely and thoroughly.
I pretty much got it!
Before the lifetime of an object has started but after the storage
which the object will occupy has been allocated or, after the lifetime
of an object has ended and before the storage which the object
occupied is reused or released,
(Condition-1)
any pointer that represents the address of the storage location where
the object will be or was located
("such a pointer")
may be used but only in limited ways.
(That means, "such a pointer" that meets "Condition-1" may be used in
limited ways. It does not say anything specific.)
For an object under construction or destruction,
(Condition-2 (special case of Condition-1))
see [class.cdtor].
(That means, "such a pointer" that meets "Condition-2" can be used as
described in [class.cdtor]).
Otherwise, such a pointer
refers to allocated storage,
(Condition-3)
and using the pointer as if the pointer were of type void*, is well-defined.
(That means, "such a pointer" that meets "Condition-3" and does not
meet "Condition-2" can be used as if the pointer were of type void*.)
Indirection through such a pointer is permitted but the resulting
lvalue may only be used in limited ways, as described below.
The program has undefined behavior if:
(That means, "such a pointer" can be used as ...)
Is it correct?
<tadeus.prastowo_at_[hidden]> wrote:
> Sentence-X is futher elaborated in Sentence-Y where Sentence-Y
> provides a forward reference, while the pointer defined in Sentence-X
> is further elaborated in Sentence-A, -B, and -C where Sentence-A, -B,
> and -C provide details and Sentence-C is the one that starts with "The
> program has undefined behavior if:" and continues to [basic.life]6.1
> up to 6.5.
Thank you for explaining so politely and thoroughly.
I pretty much got it!
Before the lifetime of an object has started but after the storage
which the object will occupy has been allocated or, after the lifetime
of an object has ended and before the storage which the object
occupied is reused or released,
(Condition-1)
any pointer that represents the address of the storage location where
the object will be or was located
("such a pointer")
may be used but only in limited ways.
(That means, "such a pointer" that meets "Condition-1" may be used in
limited ways. It does not say anything specific.)
For an object under construction or destruction,
(Condition-2 (special case of Condition-1))
see [class.cdtor].
(That means, "such a pointer" that meets "Condition-2" can be used as
described in [class.cdtor]).
Otherwise, such a pointer
refers to allocated storage,
(Condition-3)
and using the pointer as if the pointer were of type void*, is well-defined.
(That means, "such a pointer" that meets "Condition-3" and does not
meet "Condition-2" can be used as if the pointer were of type void*.)
Indirection through such a pointer is permitted but the resulting
lvalue may only be used in limited ways, as described below.
The program has undefined behavior if:
(That means, "such a pointer" can be used as ...)
Is it correct?
-- Best regards, Yo Mizu
Received on 2020-04-15 11:52:52