Re: [PATCH next 3/3] fortify: Simplify strlen() logic
From: Kees Cook
Date: Tue Mar 31 2026 - 02:07:17 EST
On Mon, Mar 30, 2026 at 02:20:03PM +0100, david.laight.linux@xxxxxxxxx wrote:
> From: David Laight <david.laight.linux@xxxxxxxxx>
>
> The __builtin_choose_expr() doesn't gain you anything, replace with
> a simple ?: operator.
> Then __is_constexpr() can then be replaced with __builtin_constant_p().
> This still works for static initialisers - the expression can contain
> a function call - provided it isn't actually called.
But __is_constexpr() != __builtin_constant_p(). I will go find the
horrible examples of why this, too, needed so much careful construction.
--
Kees Cook