Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1324495rwb; Tue, 27 Sep 2022 11:20:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6myYKRgvgaek/6OjZfYe8L3LOC/dUOg8gXli0tb/eSPsCuf7EMmdICc6hOmRQrQtdEyHES X-Received: by 2002:a17:902:b944:b0:179:fdb0:1c39 with SMTP id h4-20020a170902b94400b00179fdb01c39mr1421284pls.98.1664302838377; Tue, 27 Sep 2022 11:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664302838; cv=none; d=google.com; s=arc-20160816; b=q9vIOPnDBO6ATFFHgK2uqjrLPfOLAmJjVCf0qCrpWe72idbflA/cXdPuULAnBeF4yd zXSVvB9Dei5kc8R2U6otd2f0tIWXFfbhxe6/oCZ5RnD0thKm3bmyXDm7ce/iUfeh+8lH yukavYnQIgHWxKlHl1bAsHzmsbbwN+ggM0NSqcroSmh1XHFmuP8k1rEyFJlUckZ2ynBY b84FuhfNDUWVBLptZex/6QhOiQRGfadD8S9kUKAGNrbih5t9w2WlJiin3TeSo/JPFrAi JkhZE1YS8in7k6wxnjwb6xRB16dhEAtzQQ6DrSShJfqHvjA8/CsZlbPM83dYKW0QOcrs eE5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hxTxU30y1g6Zef9o2VP1llAzeXZ37cuaGj3GpgHAgYE=; b=RfssJ3Ps5QA0wPMwP8y6O/p+geL/UlRpwhizbsfyuOb5A3s5iCM6syxrM0QSaKJhcV CXXG8p/Mrf3ALCBWAI3oHwfYa8+F0iSRzKma3RS3q/uD4nwmtK/hczuZQZrDHF35QbFO d39kj8AZBcVs+EwiE3MJ5uKYGaCVDQeXbQk6goGo/Bp/YQGbV0ZMiYwD1LGxNxb1hrYd xXn+ivTVTLCjVKgQvZWXvb4wzBhTsrHMJ71y/+UWhStaYhRDZwzRMC//aKXQ6O3Qq+tA N99sQCvichuDWnAO7jCLSpWnpE41YJsvYg1ub2SSu6zgwQUL1UP+mpQBDj6M1yu+QUmJ Ru/A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 t9-20020a6549c9000000b00439494dfd20si2616577pgs.202.2022.09.27.11.20.26; Tue, 27 Sep 2022 11:20:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232823AbiI0QoY (ORCPT + 99 others); Tue, 27 Sep 2022 12:44:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232158AbiI0QoT (ORCPT ); Tue, 27 Sep 2022 12:44:19 -0400 Received: from mail-m118207.qiye.163.com (mail-m118207.qiye.163.com [115.236.118.207]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 057F11E05CE for ; Tue, 27 Sep 2022 09:44:16 -0700 (PDT) Received: from lyc-workstation.. (unknown [221.212.176.62]) by mail-m118207.qiye.163.com (HMail) with ESMTPA id 10B7F9016AB; Wed, 28 Sep 2022 00:44:12 +0800 (CST) From: YingChi Long To: david.laight@aculab.com Cc: bp@alien8.de, chang.seok.bae@intel.com, dave.hansen@linux.intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org, me@inclyc.cn, mingo@redhat.com, ndesaulniers@google.com, pbonzini@redhat.com, tglx@linutronix.de, x86@kernel.org Subject: RE: [PATCH v2] x86/fpu: use _Alignof to avoid UB in TYPE_ALIGN Date: Wed, 28 Sep 2022 00:44:11 +0800 Message-Id: <20220927164411.99297-1-me@inclyc.cn> X-Mailer: git-send-email 2.35.1 In-Reply-To: <38114d1b752c497eba1640360daf5b9e@AcuMS.aculab.com> References: <38114d1b752c497eba1640360daf5b9e@AcuMS.aculab.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFPN1dZLVlBSVdZDwkaFQgSH1lBWRpLTk1WGRpPHRhLQk1KSB5KVQIWExYaEhckFA4PWV dZGBILWUFZSUlKVUlKSVVKTE1VTUlZV1kWGg8SFR0UWUFZT0tIVUpKS0hNSlVKS0tVS1kG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MQg6Qxw4PjlNGTc5NE4xFDQI AgxPCT5VSlVKTU1PSUJMS05IS0NDVTMWGhIXVRYeOxIVGBcCGFUYFUVZV1kSC1lBWUlJSlVJSklV SkxNVU1JWVdZCAFZQUlIT0M3Bg++ X-HM-Tid: 0a837fd5a9cc2d29kusn10b7f9016ab X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, 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-kernel@vger.kernel.org > Interesting - what justification do they give? > Linux kernel requires that the compiler add no unnecessary padding > so that structure definitions are well defined. Yes, that's a clarification given in 2019. > So using a type definition inside offsetof() won't give a > useful value - but it still isn't really UB. WG14 may worry about commas and the scope of new definitions. So they provide new words into the standard and said: > If the specified type defines a new type or if the specified member is a > bit-field, the behavior is undefined. https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm I've provided this link in the patch. > Has that ever worked? > Given: > struct foo { > int a; > char b; > char c; > }; TYPE_ALIGN(struct foo) evaluates to 4 in the previous approach (based on offsetof). _Align(struct foo) evaluates to the same value. See https://godbolt.org/z/sqebhEnsq > I think CHECK_MEMBER_AT_END_OF_TYPE(struct foo, b) is true. Hmm, both the previous version and after this patch the macro gives me false. (See the godbolt link).