C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Lakos rule

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Thu, 21 Dec 2023 19:53:38 +0200
On Thu, 21 Dec 2023 at 19:50, Jason McKesson via Std-Proposals
<std-proposals_at_[hidden]> wrote:

> `std::align` has a precondition that `ptr` must represent an address
> of at least `space` bytes. `nullptr` doesn't represent an address.
> Therefore, if `ptr` is ever `nullptr`, the caller has invoked UB and
> it *does not matter* if the function throws.
>
> Put simply, the caller violated the standard *first*.
>
> When I said that it doesn't throw, I meant it doesn't have
> well-defined behavior for throwing. What happens if behavior is
> undefined is irrelevant because... it's undefined.

Precisely so.

Received on 2023-12-21 17:53:51