Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1710370rwb; Thu, 19 Jan 2023 14:30:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXsxPQ8KbsPJHac5T8mDkMNTkNIkAh4ayjzQoLOAA1QmiTWeDfg+OQd8HE9/7T6h5wMU6fPk X-Received: by 2002:a05:6402:27cf:b0:46b:4011:9863 with SMTP id c15-20020a05640227cf00b0046b40119863mr16864064ede.39.1674167417398; Thu, 19 Jan 2023 14:30:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674167417; cv=none; d=google.com; s=arc-20160816; b=GdmHP8I4nXNpwLbXWmsMIrJrQqpT/cfdEXBL6n2sSPOiIxAcNecJbP9aVyQJKeDsuM HFq+V7Ll/EDc69U4EwehFfy5LjkUW/Kr2cvXM+3tXlmGbiS5GJXi/SkLaoJHxzfNJukz sRoSHjnZB4CVP3oLVE2mY4Xrqt+oSsQS0jSCEvacuZp6TIKRZfrSBVNmAGhRkg7xfOfT SvluxGFJKwvZRfAT+PVW+kMFBntaYjn+WdN3gIg00b2fw21g9nmhgPzawigSUcok85uD 1GG/FOlfK8t/WBTtAz1A0QVXkmVi0PKGaKW3FyMcqb74qWjyzNKFzC+IJmTs+l4TBLDg e78A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:user-agent:mime-version:date:message-id; bh=99u4QbRJmltszSmEfDBmEyKbNIgB3K7LFPI1t4QDyBM=; b=PIp625kP+FM0mKOOTroCrj722CidyQAZ/S9fwTuCMcgHeep44ecQI28E6CeGuq8zl9 1dJYRs67UV6WbaN/us2u/agjl9i+5p359e7CocjaBv5zRaUIJ6ojvvQ/vtWcBj5LB9B9 66NZZgqdfr+VTSQKIVhNV7xgptlC8vFYeEOCtxVM5bOxOI2EWr02NKeHUB7mq6IaXask 08uM5ImB0wXi6gtXZ2BPj62YcMbqCuWaPfqe8fksBHvWTqk10HNWm6duwD5TrevoL8Oh hhxd7wfe1KA6Fdrk1wcLc73//xHV43TvPgKnDWaj3pxy8Xp5c9OclxwRwMIpdmiG7UaJ 7blQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i2-20020a0564020f0200b0048e94da0eaesi18621445eda.588.2023.01.19.14.29.59; Thu, 19 Jan 2023 14:30:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230178AbjASW02 (ORCPT + 63 others); Thu, 19 Jan 2023 17:26:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbjASWY4 (ORCPT ); Thu, 19 Jan 2023 17:24:56 -0500 Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9479A295C; Thu, 19 Jan 2023 14:11:22 -0800 (PST) Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost.zedat.fu-berlin.de (Exim 4.95) with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (envelope-from ) id 1pId7s-000ES9-TO; Thu, 19 Jan 2023 23:11:16 +0100 Received: from pd9f631ca.dip0.t-ipconnect.de ([217.246.49.202] helo=[192.168.144.87]) by inpost2.zedat.fu-berlin.de (Exim 4.95) with esmtpsa (TLS1.3) tls TLS_AES_128_GCM_SHA256 (envelope-from ) id 1pId7s-002cf1-Mu; Thu, 19 Jan 2023 23:11:16 +0100 Message-ID: <1732342f-49fe-c20e-b877-bc0a340e1a50@fu-berlin.de> Date: Thu, 19 Jan 2023 23:11:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 To: John Paul Adrian Glaubitz , Geert Uytterhoeven Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-wireless@vger.kernel.org, linux-mips@vger.kernel.org, linux-sh@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linuxppc-dev@lists.ozlabs.org, kasan-dev@googlegroups.com, linux-xtensa@linux-xtensa.org, Michael Karcher , Arnd Bergmann References: <20221227082932.798359-1-geert@linux-m68k.org> <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> From: "Michael.Karcher" Subject: Re: Calculating array sizes in C - was: Re: Build regressions/improvements in v6.2-rc1 In-Reply-To: <0d238f02-4d78-6f14-1b1b-f53f0317a910@physik.fu-berlin.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Original-Sender: Michael.Karcher@fu-berlin.de X-Originating-IP: 217.246.49.202 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Isn't this supposed to be caught by this check: >>> >>>          a, __same_type(a, NULL) >>> >>> ? >> >> Yeah, but gcc thinks it is smarter than us... >> Probably it drops the test, assuming UB cannot happen. > Hmm, sounds like a GGC bug to me then. Not sure how to fix this then. I don't see a clear bug at this point. We are talking about the C expression   __same_type((void*)0, (void*)0)? 0 : sizeof((void*)0)/sizeof(*((void*0)) This expression is valid (assuming __same_type works, which is a GCC extension), and should return 0. As of now, I have no indication that this expression does not return 0. Also, it is true that this expression contains the suspicious pattern "sizeof(void*)/sizeof(void)", which is does not calculate the size of any array. GCC is free to emit as much warnings is it wants for any kind of expressions. From a C standard point of view, it's just a "quality of implementation" issue, and an implementation that emits useless warnings is of low quality, but not non-conforming. In this case, we requested that gcc refuses to compile if it emits any kind of warning, which instructs gcc to reject programs that would be valid according to the C standard, but are deemed to be "likely incorrect". 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. Regards,   Michael Karcher