Re: git: fb84b9f400d2 - main - kern_descrip.c: only allow complex expression in Static_assert() for clang

From: Ahmad Khalifa <ahmadkhalifa570_at_gmail.com>
Date: Sun, 13 Jul 2025 00:56:51 UTC
On Sat Jul 12, 2025 at 8:57 PM +0300, Konstantin Belousov wrote:
> The branch main has been updated by kib:
>
> URL: https://cgit.FreeBSD.org/src/commit/?id=fb84b9f400d2d2bb8e1336fbacc7fbd14d31974b
>
> commit fb84b9f400d2d2bb8e1336fbacc7fbd14d31974b
> Author:     Konstantin Belousov <kib@FreeBSD.org>
> AuthorDate: 2025-07-11 18:57:32 +0000
> Commit:     Konstantin Belousov <kib@FreeBSD.org>
> CommitDate: 2025-07-12 17:56:13 +0000
>
>     kern_descrip.c: only allow complex expression in Static_assert() for clang
>
>     gcc cannot compute the assert expression, which is formally not required
>     by a C standard.
>
>     Reported and reviewed by:       jhb
>     Sponsored by:   The FreeBSD Foundation
> ---
>  sys/kern/kern_descrip.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
> index 93bdd41d1515..c4f5e586b0ed 100644
> --- a/sys/kern/kern_descrip.c
> +++ b/sys/kern/kern_descrip.c
> @@ -557,8 +557,10 @@ open_to_fde_flags(int open_flags, bool sticky_orb)
>  		{ .f = O_CLOFORK,		.t = UF_FOCLOSE },
>  		{ .f = O_RESOLVE_BENEATH,	.t = UF_RESOLVE_BENEATH },
>  	};
> +#ifdef __clang__
>  	_Static_assert(open_to_fde_flags_s[nitems(open_to_fde_flags_s) - 1].f ==
>  	    O_RESOLVE_BENEATH, "O_RESOLVE_BENEATH must be last, for sticky_orb");
> +#endif
>
>  	return (flags_trans(open_to_fde_flags_s, nitems(open_to_fde_flags_s) -
>  	    (sticky_orb ? 0 : 1), open_flags));

This doesn't compile on clang14 when cross-building do we still care
about that?

See https://github.com/freebsd/freebsd-src/actions/runs/16240751228/job/45856816666