C++ Logo


Advanced search

Re: On "transparently replaceable" in std::vector operations

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Wed, 28 Apr 2021 19:09:23 +0100
On Wed, 28 Apr 2021 at 18:44, Hyman Rosen <hyrosen_at_[hidden]> wrote:

> "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.

Another way to look at it is that by exhaustively testing your program with
sanitizers enabled, you guarantee that it lacks a class of bugs and thus
that it is safe and advantageous for the optimizer to transform your
program accordingly.

I do have some sympathy for your point of view... but we need the

Received on 2021-04-28 13:09:37