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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 29705C25B50 for ; Fri, 20 Jan 2023 11:43:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mJG3TKzCaa/rEUeapZC9aFTRokQdojX0HjAQb9OJXxw=; b=UcBywWhNz2rrSR vLGnLBGOaZhBE2aHBzPcxUhpMUOotpjePDG2yqqxmAo/iUaQn3V8pvG0TuSc2d3HQIzbOOX9bDw0t Ijmo3x+UFH5UFDvdPiiTh4bgGIMPWKTB1FfkSwq70ZCZQFkM/+Q7GwsA5MVwZfG3RHDXs24Lv1m2Y DTLhU0sz5E5dSQbyvT3AI7r7Sp7ICKmdctG4cUY3hfk70k4oFYcFnnBi7pfwmctloeBe8q7d54Cn4 rApoatXvyoB9c1GquYxo2C7oJ9T6AmwJQ6WDrDBUIw8oTNdhak329I0D3epQ13NGJRQ+VGeuyaHfD sxa/N2QcTDm3dEKwc4iQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIpnK-00A44U-EB; Fri, 20 Jan 2023 11:42:54 +0000 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pIpnH-00A42f-GX for linux-arm-kernel@lists.infradead.org; Fri, 20 Jan 2023 11:42:53 +0000 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-129-4gsduPDlOrGmwEjdKMB1gA-1; Fri, 20 Jan 2023 11:42:44 +0000 X-MC-Unique: 4gsduPDlOrGmwEjdKMB1gA-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Fri, 20 Jan 2023 11:42:42 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.044; Fri, 20 Jan 2023 11:42:42 +0000 From: David Laight To: 'Segher Boessenkool' , Rob Landley CC: "linux-xtensa@linux-xtensa.org" , "Arnd Bergmann" , "linux-sh@vger.kernel.org" , Michael.Karcher , Michael Karcher , "linux-wireless@vger.kernel.org" , "linux-mips@vger.kernel.org" , "amd-gfx@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "Geert Uytterhoeven" , "kasan-dev@googlegroups.com" , John Paul Adrian Glaubitz , "linux-f2fs-devel@lists.sourceforge.net" , "linuxppc-dev@lists.ozlabs.org" , "linux-arm-kernel@lists.infradead.org" , "linux-media@vger.kernel.org" Subject: RE: Calculating array sizes in C - was: Re: Build regressions/improvements in v6.2-rc1 Thread-Topic: Calculating array sizes in C - was: Re: Build regressions/improvements in v6.2-rc1 Thread-Index: AQHZLL5SlbpKhYJiU02AbZRDtfTmb66nLCYA Date: Fri, 20 Jan 2023 11:42:42 +0000 Message-ID: <931141d03e8748cebad42aff1a508d7f@AcuMS.aculab.com> References: <3800eaa8-a4da-b2f0-da31-6627176cb92e@physik.fu-berlin.de> <429140e0-72fe-c91c-53bc-124d33ab5ffa@physik.fu-berlin.de> <0d238f02-4d78-6f14-1b1b-f53f0317a910@physik.fu-berlin.de> <1732342f-49fe-c20e-b877-bc0a340e1a50@fu-berlin.de> <0f51dac4-836b-0ff2-38c6-5521745c1c88@landley.net> <20230120105341.GI25951@gate.crashing.org> In-Reply-To: <20230120105341.GI25951@gate.crashing.org> 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-Originator: aculab.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230120_034251_854567_1F5F008F X-CRM114-Status: GOOD ( 16.73 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Segher Boessenkool > Sent: 20 January 2023 10:54 ... > > > I suggest to file a bug against gcc complaining about a "spurious > > > warning", and using "-Werror -Wno-error-sizeof-pointer-div" until gcc is > > > adapted to not emit the warning about the pointer division if the result > > > is not used. > > Yeah. If the first operand of a conditional operator is non-zero, the > second operand is not evaluated, and if the first is zero, the third > operand is not evaluated. It is better if we do not warn about > something we do not evaluate. In cases like here where it is clear at > compile time which branch is taken, that shouldn't be too hard. > > Can someone please file a GCC PR? With reduced testcase preferably. It's not a bug. All the operands of the conditional operator have to be valid. It might be that the optimiser can discard one, but that happens much later on. Even the operands of choose_expr() have to be valid - but can have different types. I'm not sure what the code is trying to do or why it is failing. Was it a fail in userspace - where the option to allow sizeof (void) isn't allowed. FWIW you can check for a compile-time NULL (or 0) with: #define is_null(x) (sizeof *(0 : (void *)(x) ? (int *)0) != 1) Although that is a compile-time error for non-NULL unless 'void *' arithmetic is allowed. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel