From nobody Wed Aug 26 18:50:47 2026 X-Original-To: hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hVYd85lnnz6qV51; Wed, 26 Aug 2026 18:50:52 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hVYd845xdz3H0g; Wed, 26 Aug 2026 18:50:52 +0000 (UTC) (envelope-from glebius@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787770252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OCAM9e0qZ+h8wozLpVibKaC9UYPEFYCucsJfPJ9Ddsc=; b=tUUA8Mw99xXxRM5bcRogUl9gTGpHoLG0OQQzphHHdpfM0r8FrABifv1s4cDHa4S1wdA6Nb uM6ZrHh7mFQbiAhYbrkNeWdIXyAGcaWQlHhoZyVK2uirRWflR7utSKc8eH0BhBNVdaomay LrSkQvYKZhZC04tEu7btyZt8bhrf/6lO7kokQlsVkiXZcOpEV1pKV0AVA20Xvz/fXpgR48 t4SWalspQ31x2aUt8u/CW7RaDNdB/75DBsRfctVuvrYSUta3bsPZxk3tdEbGyUq2Cxtzet pgX5v3HsPLrhxYRetPiOn41UgaT1P93JXcujULryLr7kQKKtPrea07P4OpU26g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1787770252; a=rsa-sha256; cv=none; b=Zk4Buvwfv6suiXefezvhf1/6KK3hCNhPkf2qqgSpWEK3keaA2/x9GUDrDK+CWIFcCp91UJ viScyVXL6JKRuY13WSjJr/KsubdTHnflbS3MJvzY0J0SfzYl2qlqDj8ZESbA5FbSZNhcK3 xGzzY4bbc9GkeCArzCwUvZs1jHGOcOnCgBD4CYjd68VFJpWr1mKRhfMFtnQYWqRKvl9pmf 1qZ8p2+/TLoolMHvaczXAJy7pQRT+i9OtRd1M6MDugnT3BzvsUgjiPRmZ4XiUJ5mqsKhZg q11lpcEjtfCgTGlW+AZpzOrLzSXU3VO1Wja1VJ/NdiqO1xoLKlyoIp/1TOz8Ig== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1787770252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OCAM9e0qZ+h8wozLpVibKaC9UYPEFYCucsJfPJ9Ddsc=; b=prljVXpwLZOSFAIcqLtLMA2OSYtTkIXlC3Rcp7a9MDuRA9x36pGfJA8QVlnuoEPZoIDx3+ e0I8t+ABlSgNp11gtJ+6HUbx96z+IRfl0dtWWOS02N+lZXZEevCgRwhckKrnZqPbAfJ6VY rqrlEVIaBhy1TibE1u8Agyr2HoWpGneX1znrT4cfdpozJlwkKvSx8+Lq/WJ0P6QGwmk2cm 613ijDGsmFSyAg+1qnTyB7m44fsNOzH0YFCV5CVIfa/OvLXFhZiL+STJGp//nuGv0Mp+7x raaYzZfj+H/FOag8jUOo0ccteNyio86QiTwRHBp1SPemWWJShJVAUFaGm4VKlg== Received: from cell.glebi.us (glebi.us [162.251.186.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: glebius) by smtp.freebsd.org (Postfix) with ESMTPSA id 4hVYd75RrJzjsd; Wed, 26 Aug 2026 18:50:51 +0000 (UTC) (envelope-from glebius@freebsd.org) Date: Wed, 26 Aug 2026 11:50:47 -0700 From: Gleb Smirnoff To: Kyle Evans Cc: John Baldwin , current@freebsd.org, hackers@freebsd.org Subject: Re: enabling -Werror=assign-enum for kernel Message-ID: References: <0e34f0c6-b41a-49d3-9c41-3ec84ea2e0be@FreeBSD.org> List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Aug 26, 2026 at 01:03:44PM -0500, Kyle Evans wrote: K> > On Wed, Aug 26, 2026 at 01:15:27PM -0400, John Baldwin wrote: K> > J> > J> Note that C++ doesn't allow this at the language level. When I converted ctld to K> > J> > J> C++ I had to adjust some enums to be simple #define's instead in the ctl headers. K> > J> > K> > J> > Noted. I can't make a judgement if it is a smart restriction by C++ or not. K> > J> > In our case using enums as flags is common and handy and Werror=assign-enum in K> > J> > combination with __attribute__((flag_enum)) will make this use fortified K> > J> > against mistakes. K> > J> K> > J> Mostly my point is that over time we may be forced to convert away from enums to K> > J> plain constants if more of the base system starts using C++ anyway. At least for K> > J> enums exposed to userspace. K> > K> > But if C++ doesn't allow flag enums in principle, then they just can't go into K> > userspace headers, no matter how we compile the kernel. Basically we already K> > are there, and enabling Werror=assign-enum for kernel won't change anything, K> > will it? K> > K> I don't really have comments on the rest of this, but at least one of our downstreams does K> use C++ in the kernel and it'd be nice if we didn't have anything too critical require too K> heavy of patching to work in that environment. This basically means we can't use flag enums in KPIs, but we can internally. My recent sweep through the code seems to confirm that we don't have any KPIs that use flag enums. Note. Actually it is possible to use C flag enums in C++ with cast: Flags f = static_cast(FLAG_A | FLAG_B); Not saying that we should propose such KPIs. On other hand, if we ever get to massive use of C++ in kernel, we can propose a specific C++ KPI with class enums and specific C KPI with flag enums. -- Gleb Smirnoff