John Baldwin <jhb_at_FreeBSD.org> wrote on Date: Fri, 11 Jul 2025 15:46:33 UTC :
> On 7/8/25 17:49, Konstantin Belousov wrote: > > The branch main has been updated by kib: > > > > URL: > > https://cgit.FreeBSD.org/src/commit/?id=ba0d9b43e940077f4025e7e4e85d16c8d525db79 > > > > commit ba0d9b43e940077f4025e7e4e85d16c8d525db79 > > Author: Konstantin Belousov <k...@freebsd.org> > > AuthorDate: 2025-07-08 16:30:29 +0000 > > Commit: Konstantin Belousov <k...@freebsd.org> > > CommitDate: 2025-07-08 21:48:59 +0000 > > > > kern_descrip.c: provide helpers to translate between fd flags namespace > > > > Reviewed by: markj > > Sponsored by: The FreeBSD Foundation > > Differential revision: https://reviews.freebsd.org/D51206 > > --- > > sys/kern/kern_descrip.c | 110 > > +++++++++++++++++++++++++++++++++++++++--------- > > 1 file changed, 90 insertions(+), 20 deletions(-) > > > > diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c > > index 406236fc2723..2e1da2fdee29 100644 > > --- a/sys/kern/kern_descrip.c > > +++ b/sys/kern/kern_descrip.c > > @@ -480,6 +480,90 @@ kern_fcntl_freebsd(struct thread *td, int fd, int cmd, > > intptr_t arg) > > return (error); > > } > . . . > > + > > +static uint8_t > > +open_to_fde_flags(int open_flags, bool sticky_orb) > > +{ > > + static const struct flags_trans_elem open_to_fde_flags_s[] = { > > + { .f = O_CLOEXEC, .t = UF_EXCLOSE }, > > + { .f = O_CLOFORK, .t = UF_FOCLOSE }, > > + { .f = O_RESOLVE_BENEATH, .t = UF_RESOLVE_BENEATH }, > > + }; > > + _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"); > > This broke the GCC builds it seems. GCC doesn't think that it can compute this > expression at compile time. > > From https://ci.freebsd.org/job/FreeBSD-main-amd64-gcc14_build/1022/console: > > 10:32:02 /workspace/src/sys/kern/kern_descrip.c: In function > 'open_to_fde_flags': > 10:32:02 /workspace/src/sys/kern/kern_descrip.c:560:79: error: expression in > static = > 10:32:02 assertion is not constant > 10:32:02 560 | _Static_assert(open_to_fde_flags_s[nitems(open_to_fde_flags= > 10:32:02 _s) - 1].f =3D=3D In trying to figure this out, what I ran into was . . . QUOTE from: 6.6 Constant expressions (N3220 working draft) . . . The array-subscript [] and member-access -> operator, the address & and indirection * unary operators, and pointer casts may be used in the creation of an address constant, but the value of an object shall not be accessed by use of these operators. 119) . . . 119) Named constants or compound literal constants with arithmetic type, including names of constexpr objects, are valid in offset computations such as array subscripts or in points casts, as long as the expressions in which they occur form integer constant expressions. In contrast, names of other objects, even if const-qualified and with static storage duration, are not valid. END QUOTE It looks to me like gcc is avoiding allowing use of an extension to what the language definition provides as guarantees for what is a valid integer constant expression. === Mark Millard marklmi at yahoo.com