From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28253 invoked from network); 26 May 2023 19:30:08 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 26 May 2023 19:30:08 -0000 Received: (qmail 14055 invoked by uid 550); 26 May 2023 19:30:05 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 14023 invoked from network); 26 May 2023 19:30:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version; bh=YDKZCmyTweGYbbi+uxseNvA1AHDLAmPtHQJwYr3dFa0=; b=Jc84oTp9fcJ8hN2KqXi/aOs6FM5hp5TFkTzkOysE9/zXRk3gKQ2K1UJC BJDFbHHKeyNyk8izLSZ+223Q3shNnR47gEVpLPz7JWsjpvHBgPmRoajHb ZAGrpow9cExQH2CCZlVDP0ie4hFw5zq/0DmBqBGSRoycq4YOJxWRRTmhz M=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=jens.gustedt@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.00,195,1681164000"; d="scan'208";a="109946693" Date: Fri, 26 May 2023 21:29:51 +0200 From: =?UTF-8?B?SuKCkeKCmeKCmw==?= Gustedt To: NRK Cc: musl@lists.openwall.com Message-ID: <20230526212951.148fc424@inria.fr> In-Reply-To: <20230526172037.o2l4y63edb3k2n3n@gen2.localdomain> References: <26b68deb9fc65f8331c7fedaa6d807f4d973a4e6.1684932942.git.Jens.Gustedt@inria.fr> <3a4f4a8e-9179-6606-e449-6fc2812d3525@mulle-kybernetik.com> <20230526172037.o2l4y63edb3k2n3n@gen2.localdomain> Organization: inria.fr X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) X-Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAACRQTFRFERslNjAsLTE9Ok9wUk9TaUs8iWhSrYZkj42Rz6aD3sGZ MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/tWrnit6.UZPm=A7M/uFbUtY"; protocol="application/pgp-signature"; micalg=pgp-sha1 Subject: Re: [musl] [C23 const 1/2] C23: change bsearch to a macro that respects the const contract --Sig_/tWrnit6.UZPm=A7M/uFbUtY Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable on Fri, 26 May 2023 23:20:37 +0600 you (NRK ) wrote: > On Fri, May 26, 2023 at 01:29:31PM +0200, Nat! wrote: > > I think it's sort of obvious, that these macros increase code > > brittleness due to now multiple execution of macro arguments vs. a > > single execution in a function call. =20 >=20 > It would be heavily surprising if the controlling expression of > _Generic was evaluated. Similar to `sizeof`, it only needs to know > the type of the expression and thus doesn't require evaluation (only > exception being VLAs in a sizeof). Yes, exactly, that's the idea. And VLA (and similar) are not allowed for the controling expression of a generic selection, so this problem does not arise, there. > | The controlling-expression and the expressions of the selections > that | are not chosen are never evaluated. >=20 > However, there is one thing that I don't quite understand about this > patch: >=20 > > + void const*: (void const*)bsearch((K), (void > > const*)(B), (N), (S), (C)), \ =20 >=20 > What's with the `(void const*)(B)` cast? It's already determined to be > `void const *` via _Generic. Even if not evaluated, all branches have to be syntactically and semantically correct. If you don't use these kind of casts, you may get a lot of warnings. This "feature" makes the use of these beast a bit subtle, sometimes. (Originally, generic selection had been designed to chose between different function pointers similar as in to implement something like overloading.) Thanks J=E2=82=91=E2=82=99=E2=82=9B --=20 :: ICube :::::::::::::::::::::::::::::: deputy director :: :: Universit=C3=A9 de Strasbourg :::::::::::::::::::::: ICPS :: :: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus :: :: :::::::::::::::::::::::::::::::::::: =E2=98=8E +33 368854536 :: :: https://icube-icps.unistra.fr/index.php/Jens_Gustedt :: --Sig_/tWrnit6.UZPm=A7M/uFbUtY Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSN9stI2OFN1pLljN0P0+hp2tU34gUCZHEIrwAKCRAP0+hp2tU3 4undAJ4u5uLKrFXD9mlgtuyi+6BkA9wi8wCghA8ytKspNUKrdBxyzX67sgyYNAo= =ZmQj -----END PGP SIGNATURE----- --Sig_/tWrnit6.UZPm=A7M/uFbUtY--