From owner-svn-src-all@freebsd.org Sat Feb 22 19:01:49 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BDF6124961C; Sat, 22 Feb 2020 19:01:49 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "tensor.andric.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48PyNr2Q18z4Vbs; Sat, 22 Feb 2020 19:01:48 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from [IPv6:2001:470:7a58::b8df:abc8:d12f:4fd2] (unknown [IPv6:2001:470:7a58:0:b8df:abc8:d12f:4fd2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 44A432CB41; Sat, 22 Feb 2020 20:01:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=andric.com; s=201904; t=1582398100; bh=fJ35Wuwd/5febS7ZP1tdlW0LXHfRj3wu8F0yo4/gb5U=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=NSHiC4bcR7Dv4Wt/nDQhaKNVK0Pymv21hzmw8RDDC4vl45Hdq1xCEKw3Z/9WySSVc xP7WsOj3mkGRp3jo1fWwmGDRIapkM5HjV5DpZbEnToSdqqPP5KHyLrOQ4X4YGvpk8m j296VLJLkdMIfTqrBYjFas6H0urxePIxrpXfX2XfCuQxhk5KVjoAvQpm73aRQ0pBgW DJHd0PpW/g5xN0hw+54zLb+0GlLdvdQpfr8RikVzJKcnepHR87L+WfrnZYPp8sqD9d moIhaxld1PInrFqGyRbhRrzc9SVa0WzuxgWtUgA5Kq4R/T+CN7lSJcdoPNlu7V80a9 6Iz4zYzKbvuAw== From: Dimitry Andric Message-Id: <6D39FAD8-E581-42A8-97B4-EE63800D78A4@andric.com> Content-Type: multipart/signed; boundary="Apple-Mail=_4EE71C4E-25DB-4EEE-BBA3-0EE610EB99DD"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Subject: Re: svn commit: r358248 - head/sys/vm Date: Sat, 22 Feb 2020 20:01:31 +0100 In-Reply-To: Cc: Kyle Evans , Ian Lepore , svn-src-head , svn-src-all , src-committers To: Mateusz Guzik References: <202002221620.01MGK46E072303@repo.freebsd.org> X-Mailer: Apple Mail (2.3445.104.11) X-Rspamd-Queue-Id: 48PyNr2Q18z4Vbs X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=andric.com header.s=201904 header.b=NSHiC4bc; dmarc=pass (policy=none) header.from=andric.com; spf=pass (mx1.freebsd.org: domain of dimitry@andric.com designates 87.251.56.140 as permitted sender) smtp.mailfrom=dimitry@andric.com X-Spamd-Result: default: False [-4.93 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[andric.com:s=201904]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:87.251.56.140]; MV_CASE(0.50)[]; HAS_ATTACHMENT(0.00)[]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCPT_COUNT_FIVE(0.00)[6]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[andric.com:+]; DMARC_POLICY_ALLOW(-0.50)[andric.com,none]; SIGNED_PGP(-2.00)[]; FREEMAIL_TO(0.00)[gmail.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-0.33)[asn: 12859(-1.68), country: NL(0.03)]; ASN(0.00)[asn:12859, ipnet:87.251.32.0/19, country:NL]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Feb 2020 19:01:49 -0000 --Apple-Mail=_4EE71C4E-25DB-4EEE-BBA3-0EE610EB99DD Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 22 Feb 2020, at 17:44, Mateusz Guzik wrote: >=20 > On 2/22/20, Kyle Evans wrote: >> On Sat, Feb 22, 2020 at 10:25 AM Ian Lepore wrote: >>>=20 >>> On Sat, 2020-02-22 at 16:20 +0000, Kyle Evans wrote: >>>> Author: kevans >>>> Date: Sat Feb 22 16:20:04 2020 >>>> New Revision: 358248 >>>> URL: https://svnweb.freebsd.org/changeset/base/358248 >>>>=20 >>>> Log: >>>> vm_radix: prefer __builtin_unreachable() to an unreachable panic() >>>>=20 >>>> This provides the needed hint to GCC and offers an annotation for >>>> readers to >>>> observe that it's in-fact impossible to hit this point. We'll get = hit >>>> with a >>>> a -Wswitch error if the enum applicable to the switch above were = to >>>> get >>>> expanded without the new value(s) being handled. >>>>=20 >>>> Modified: >>>> head/sys/vm/vm_radix.c >>>>=20 >>>> Modified: head/sys/vm/vm_radix.c >>>> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >>>> --- head/sys/vm/vm_radix.c Sat Feb 22 13:23:27 2020 = (r358247) >>>> +++ head/sys/vm/vm_radix.c Sat Feb 22 16:20:04 2020 = (r358248) >>>> @@ -208,8 +208,7 @@ vm_radix_node_load(smrnode_t *p, enum >>>> vm_radix_access >>>> case SMR: >>>> return (smr_entered_load(p, vm_radix_smr)); >>>> } >>>> - /* This is unreachable, silence gcc. */ >>>> - panic("vm_radix_node_get: Unknown access type"); >>>> + __unreachable(); >>>> } >>>>=20 >>>> static __inline void >>>=20 >>> What does __unreachable() do if the code ever becomes reachable? = Like >>> if a new enum value is added and this switch doesn't get updated? >>>=20 >>=20 >> __unreachable doesn't help here, but the compiler will error out on >> the switch() if all enum values aren't addressed and there's no >> default: case. >>=20 >> IMO, compilers could/should become smart enough to error if there's = an >> explicit __builtin_unreachable() and they can trivially determine = that >> all paths will terminate before this, independent of -Werror=3Dswitch*.= >> _______________________________________________ >=20 > I think this is way too iffy, check this program: >=20 >=20 > #include >=20 > int > main(void) > { >=20 > __builtin_unreachable(); > printf("test\n"); > } >=20 > Neither clang nor gcc warn about this and both stop code generation > past the statement. Indeed, that is exactly the intent. See: = https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html#index-_005f_005fbui= ltin_005funreachable "If control flow reaches the point of the __builtin_unreachable, the program is undefined. It is useful in situations where the compiler cannot deduce the unreachability of the code." E.g. this is *not* meant as a way to enforce the program to abort at runtime, if the supposedly unreachable part is actually reached. For this purpose, one should use an abort() or panic() function call, with such functions being annotated to never return. -Dimitry --Apple-Mail=_4EE71C4E-25DB-4EEE-BBA3-0EE610EB99DD Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCXlF6iwAKCRCwXqMKLiCW o+LFAKDkDeedeFuXnYA+mz0c6EBY9BQHiACgz5xy6bzXcWSFVoj8uqYyquFHfkk= =tmbs -----END PGP SIGNATURE----- --Apple-Mail=_4EE71C4E-25DB-4EEE-BBA3-0EE610EB99DD--