Date: Wed, 05 Jul 2023 18:54:49 -0700
On Wednesday, 5 July 2023 18:46:59 PDT Jason McKesson via Std-Proposals wrote:
> > In this implementation, the "silent_at" method performs bounds checking by
> > comparing the specified index to the length of the container. If the
> > index is greater than or equal to the length, indicating an out-of-bounds
> > access, the program crashes using __builtin_trap(). Since the method is
> > marked as noexcept, the compiler is free to optimize it as needed,
> > including reordering the trap.
> So it's just an assert that doesn't go away in non-debug builds? I
> don't know; this sounds vaguely like contracts to me.
And a crash is hardly silent.
If the objective is to use assertions, why can't they be added to operator[]?
> > In this implementation, the "silent_at" method performs bounds checking by
> > comparing the specified index to the length of the container. If the
> > index is greater than or equal to the length, indicating an out-of-bounds
> > access, the program crashes using __builtin_trap(). Since the method is
> > marked as noexcept, the compiler is free to optimize it as needed,
> > including reordering the trap.
> So it's just an assert that doesn't go away in non-debug builds? I
> don't know; this sounds vaguely like contracts to me.
And a crash is hardly silent.
If the objective is to use assertions, why can't they be added to operator[]?
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Software Architect - Intel DCAI Cloud Engineering
Received on 2023-07-06 01:54:51