From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF43EE77173 for ; Fri, 6 Dec 2024 19:44:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B8B110E61D; Fri, 6 Dec 2024 19:44:31 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by gabe.freedesktop.org (Postfix) with ESMTPS id E5E2510E61E for ; Fri, 6 Dec 2024 19:44:29 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-117-WxcFF2J0PnutzUqsQ_ZSew-1; Fri, 06 Dec 2024 19:44:26 +0000 X-MC-Unique: WxcFF2J0PnutzUqsQ_ZSew-1 X-Mimecast-MFC-AGG-ID: WxcFF2J0PnutzUqsQ_ZSew Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Fri, 6 Dec 2024 19:43:39 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Fri, 6 Dec 2024 19:43:39 +0000 From: David Laight To: 'Willy Tarreau' , Linus Torvalds CC: Vincent Mailhol , Luc Van Oostenryck , Nathan Chancellor , "Nick Desaulniers" , Bill Wendling , Justin Stitt , Yury Norov , Rasmus Villemoes , Kees Cook , "Gustavo A. R. Silva" , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Simona Vetter , Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Rikard Falkeborn , "linux-sparse@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "llvm@lists.linux.dev" , "linux-hardening@vger.kernel.org" , "intel-gfx@lists.freedesktop.org" , "dri-devel@lists.freedesktop.org" , "coresight@lists.linaro.org" , "linux-arm-kernel@lists.infradead.org" , "uecker@tugraz.at" Subject: RE: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr() Thread-Topic: [PATCH 02/10] compiler.h: add is_const() as a replacement of __is_constexpr() Thread-Index: AQHbROFPJXcuwP9wN0+yRzIQ2cx/pbLWa+gggAFf14CAACMqUIABpzoGgAAClHCAAAo1Y4AAAKpg Date: Fri, 6 Dec 2024 19:43:39 +0000 Message-ID: <8f4b7d1bfbd84885bddf4cc1dfb9ce43@AcuMS.aculab.com> References: <20241203-is_constexpr-refactor-v1-0-4e4cbaecc216@wanadoo.fr> <20241203-is_constexpr-refactor-v1-2-4e4cbaecc216@wanadoo.fr> <1d807c7471b9434aa8807e6e86c964ec@AcuMS.aculab.com> <9ef03cebb4dd406885d8fdf79aaef043@AcuMS.aculab.com> <20241206193836.GA26860@1wt.eu> In-Reply-To: <20241206193836.GA26860@1wt.eu> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: S78HpnSWM5tVMMZIiQy4YkVPIQveoqojJvjPExAwQpw_1733514265 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Willy Tarreau > Sent: 06 December 2024 19:39 > On Fri, Dec 06, 2024 at 11:15:20AM -0800, Linus Torvalds wrote: > > On Fri, 6 Dec 2024 at 11:07, David Laight wro= te: > > > > > > I'm missing the compiler version and options to generate the error. > > > > Just -Wall with most recent gcc versions seems to do it. At least I > > can repro it with gcc-14.2.1 and something silly like this: > > > > $ cat t.c > > int fn(int a) { return (a<<2)?1:2; } > > $ gcc -Wall -S t.c > > t.c: In function 'fn': > > t.c:1:26: warning: '<<' in boolean context, did you mean '<'? > > [-Wint-in-bool-context] > > > > > Does a '+ 0' help? "(var << 2) + 0 ? 0 : 0" > > > > Yeah, that actually works. > > > > And "+0" is nice in that it should work in any context. >=20 > I've already used "+0" to shut certain warnings, I don't really remember > which one, but also remember it was OK everywhere I needed. I've often used +0u when -Wsign-compare is enabled. Much safer than a cast. >=20 > Another trick I've been using to shut up the compiler is a cast via typeo= f > and an intermediary variable: >=20 > #define shut_up(expr) \ > ({ \ > typeof(expr) _expr_ =3D expr; \ > _expr_; \ > }) That is like OPTIMISER_HIDE_VAR() and can't be used in a 'constant integer = expression'. I suspect it also has the same nasty habit of adding an extra register move= . =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)