Date: Thu, 22 Jan 2026 22:32:00 -0800
On Thursday, 22 January 2026 21:55:50 Pacific Standard Time Jan Schultke via
Std-Proposals wrote:
> Clang rejects that code, but simply on the basis that constant evaluation
> hits something that's UB. Clang is already allowed to do that. What I'm
> suggesting is that the call to std::bit_cast should be ill-formed because
> it's unconditionally UB, and thus indicative of a programmer error, even if
> never evaluated.
That may be the case, but it's not what the Standard says. If the Standard
says it's UB, then it's perfectly fine to exist and compile, so long as it's
never triggered.
To reject at compile time, it needs to become ill-formed.
But I'd rather we defined the behaviour.
Std-Proposals wrote:
> Clang rejects that code, but simply on the basis that constant evaluation
> hits something that's UB. Clang is already allowed to do that. What I'm
> suggesting is that the call to std::bit_cast should be ill-formed because
> it's unconditionally UB, and thus indicative of a programmer error, even if
> never evaluated.
That may be the case, but it's not what the Standard says. If the Standard
says it's UB, then it's perfectly fine to exist and compile, so long as it's
never triggered.
To reject at compile time, it needs to become ill-formed.
But I'd rather we defined the behaviour.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-01-23 06:32:04
