Date: Wed, 28 Apr 2021 13:44:16 -0400
"close off a class of correctness checking"
Except, of course, what happens is that when the compiler detects one of
these uses of an invalidated pointer, it silently uses the undefined
behavior permission to subvert the program and produce wrong results from
the point of view of the programmer. That is, it opens up a new class of
silent and deadly errors that would not be there without this pointer
invalidation.
On Wed, Apr 28, 2021, 11:13 AM Edward Catmur via Std-Discussion <
std-discussion_at_[hidden]> wrote:
> On Wed, 28 Apr 2021 at 11:53, Giuseppe D'Angelo via Std-Discussion <
> std-discussion_at_[hidden]> wrote:
>
>> In such a case, doesn't this sentence guarantee that the pointer now
>> points to the new object constructed at that position?
>>
>> > http://eel.is/c++draft/basic.memobj#basic.life-8.sentence-1
>
>
> Right, yeah, sorry. I agree, the pointers and references should continue
> to be usable to access the new object (or the original object with the new
> value, if the shuffle is accomplished by assignment).
>
> That said, a library implementation that has access to magic could
> invalidate the pointers and references if it expends sufficient effort; for
> example, pointer tagging.
>
> So allowing the pointers and references to be used after insert would
> close off a class of correctness checking; the question is whether at
> present use of a pointer/reference (or, indeed, an iterator) after an
> insert is more likely to be intentional or a bug.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
Except, of course, what happens is that when the compiler detects one of
these uses of an invalidated pointer, it silently uses the undefined
behavior permission to subvert the program and produce wrong results from
the point of view of the programmer. That is, it opens up a new class of
silent and deadly errors that would not be there without this pointer
invalidation.
On Wed, Apr 28, 2021, 11:13 AM Edward Catmur via Std-Discussion <
std-discussion_at_[hidden]> wrote:
> On Wed, 28 Apr 2021 at 11:53, Giuseppe D'Angelo via Std-Discussion <
> std-discussion_at_[hidden]> wrote:
>
>> In such a case, doesn't this sentence guarantee that the pointer now
>> points to the new object constructed at that position?
>>
>> > http://eel.is/c++draft/basic.memobj#basic.life-8.sentence-1
>
>
> Right, yeah, sorry. I agree, the pointers and references should continue
> to be usable to access the new object (or the original object with the new
> value, if the shuffle is accomplished by assignment).
>
> That said, a library implementation that has access to magic could
> invalidate the pointers and references if it expends sufficient effort; for
> example, pointer tagging.
>
> So allowing the pointers and references to be used after insert would
> close off a class of correctness checking; the question is whether at
> present use of a pointer/reference (or, indeed, an iterator) after an
> insert is more likely to be intentional or a bug.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
Received on 2021-04-28 12:44:32