C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: On "transparently replaceable" in std::vector operations
From: language.lawyer_at_[hidden]
Date: 2021-06-23 05:55:22


On 23/06/2021 12:49, Lénárd Szolnoki via Std-Discussion wrote:
> Hi,
>
> In my reading the pointer value itself can become invalid, the pointer doesn't need to change value.

I don't understand what does «value itself can become invalid» mean.
  
> The value of a trivially copyable type is determined from its value representation.

This is not correct. And it is easy to show counterexamples, especially with pointer values.

> The value representation can only change when the object is accessed.

If assume that accessing a value representation means accessing the object, this claim becomes trivial/tautological/irrefutable. (If a program reads the value representation twice and discovers that it has changed, this is because it accessed the object and thus changed its value representation).

> But a pointer can become invalid without accessing it, therefore it's the value itself that has to become invalid in that case.

The conclusion may follow from the premise, however, the premise feels like your postulate.

> Cheers,
> Lénárd


STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups