Date: Tue, 19 May 2026 16:09:29 -0700
On Tuesday, 19 May 2026 12:46:58 Pacific Daylight Time Jonathan Wakely via Std-
Proposals wrote:
> > One trick people are using is to put this in the body:
> > static_assert(1 == 2, "Func must only be used in an unevaluated
> >
> > context");
>
> That can't even be compiled, even if it's never used in any context,
> evaluated or not.
He probably meant
assert(1 == 2 && "Func must only be used in an unevaluated context");
as in https://gcc.godbolt.org/z/xWsfPr7fY
Though I'd follow that with __builtin_unreachable() or __builtin_trap(), or
use an assert() replacement that falls back to [[assume]] in release mode.
Proposals wrote:
> > One trick people are using is to put this in the body:
> > static_assert(1 == 2, "Func must only be used in an unevaluated
> >
> > context");
>
> That can't even be compiled, even if it's never used in any context,
> evaluated or not.
He probably meant
assert(1 == 2 && "Func must only be used in an unevaluated context");
as in https://gcc.godbolt.org/z/xWsfPr7fY
Though I'd follow that with __builtin_unreachable() or __builtin_trap(), or
use an assert() replacement that falls back to [[assume]] in release mode.
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-05-19 23:09:54
