Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp235000pxb; Mon, 13 Sep 2021 17:56:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzl4Dc70t4ZDSOtaKLnAzKEuK2DnSqLgoVj3YXdV0a2m9eKC3a4Xd/JWLeuSwT32ZOOxCAb X-Received: by 2002:a17:906:4758:: with SMTP id j24mr16053455ejs.46.1631581015559; Mon, 13 Sep 2021 17:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631581015; cv=none; d=google.com; s=arc-20160816; b=fMhEiGG0mWOZkt1SEqctoWemPXVVxk6M+MD43Epf3kCIl/nOY9jPf951AtgfVUGv7+ 0btyBQDBCX6ICd+diTrKr6eFsaF72sfV/WaVBNuBChv3ONbJn33S/qMQZTjsy9no/TJu 6+Hlu+7KnC6Tjk8+wHAS0xlwivAG4AwDPhxTbFDQ4N53r4EVNMn53CpLA3ml+tvd+jLF bVxEmtjjLbOryodCnNpZI07SOABOIX82sg4KMAsoWvKIKLhq4DTLV/lWjtV1cDMDjmUq tCDuJpzQXy9bdiZ87VlFVxrUZDPX4YjDeEm7qvl9htNwn5dmCDPKRRSlYPvbDkcw3qsL J0cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Ab1WFZJmYikJoccQlR3NxFKWDUFBnjkVqWNG5aDGudM=; b=w8TM37pErDMN+7/19te6PPdFL6kGN3NNv4xFCeoFL3UNZTy/45ckyntqKnQ7nvFkcx f3DxVp8nRbYePSnRaj43F7jsJ8fLeQCbdpyHxmY7jZXkK6tNkJnHzuB4ZHFUIg8nk6E0 7OQhJ9HHiY4XiC6KZFklqYqhR9o8swTq7Kim6d9d4ud+2V91rvJ/Blh79WxnbwnzRnuM EBhggSwp7MUr9oZ1QmjmF3vnrHvQI5m25kVN2PnLz+vuqhqcNoy+k0yt/l0f+L2zHSdD XCMFKHr9/NIWD27c6iYkRhi71/VB4yAajgC58/25tO593nsT1N5M4WYLTdSApkgUlMSh rtGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mIkxzX47; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y25si8696552edq.73.2021.09.13.17.56.31; Mon, 13 Sep 2021 17:56:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mIkxzX47; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229735AbhIMTPE (ORCPT + 99 others); Mon, 13 Sep 2021 15:15:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:39624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbhIMTPD (ORCPT ); Mon, 13 Sep 2021 15:15:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ED6E3610D2; Mon, 13 Sep 2021 19:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631560427; bh=KmdY/RcrurEpeFE6+3oVxeC2jaOaMBgou37s+DP3su4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=mIkxzX47RFw1gfvvBuTgHBaMpbrbo1CZTJdSLBiFqLWlYcS8fzb13UmQCs14mhsZr Kc/9R/r3XH2U79TubJVBY/j81BqUNGfRCA9HLQHgzkEZxSA2P/sla6qJfcd0sNxCPn pAbZWzcv/j5nCKB1OI8ejFr3FEEkF5OesnOb1dJSLH36TsOBR97CD6v1X3Mhvp7NWL VB1wQ+fYg8R74xZr5Oyiizt7JaJ4d01qIOm8CiBBAJ1Oh58GO3hyVHPi4qN/dQPO5L PYqPfetKri9Q/0nBExTvUg0+H94gAN5ImDme2rOT+7D0Y3OoOoZYJCqgXlv3S1Qzx3 ryfezWHtZscHw== Subject: Re: drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression To: Jason Gunthorpe Cc: Nick Desaulniers , kernel test robot , llvm@lists.linux.dev, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <202109112002.NZceUwiC-lkp@intel.com> <20210913165317.GX2505917@nvidia.com> <20210913183813.GY2505917@nvidia.com> <20210913190246.GA4065468@nvidia.com> From: Nathan Chancellor Message-ID: <0158604c-8777-51c8-2cb5-b7f016335786@kernel.org> Date: Mon, 13 Sep 2021 12:13:45 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210913190246.GA4065468@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/13/2021 12:02 PM, Jason Gunthorpe wrote: > On Mon, Sep 13, 2021 at 11:53:25AM -0700, Nathan Chancellor wrote: >> On Mon, Sep 13, 2021 at 03:38:13PM -0300, Jason Gunthorpe wrote: >>> On Mon, Sep 13, 2021 at 10:00:02AM -0700, Nick Desaulniers wrote: >>> >>>>> This macro would like to know that the passed in member name has a u64 >>>>> type, all the things I've come up with fail on clang - but many work >>>>> fine on gcc. Frankly I think this case is a clang bug myself.. >>>> >>>> Perhaps, though this assertion looks a bit like offsetof() to me. I >>>> wonder if that can help here? >>> >>> The assertion would logically like to be this: >>> >>> static_assert(typecheck(((struct qib_port *)0)->N, u64)) >> >> This works for me with both GCC and clang, if that is acceptable to you? >> It fails if you change one of the variables to 'u32'. > > Yes, thanks. Can't say I've even heard of __same_type before :\ would > be nice if this was in typecheck.h along with the other variations of > the same idea. Presumably it is a little bit different from those > somehow? Good question... commit d2c123c27db8 ("module_param: add __same_type convenience wrapper for __builtin_types_compatible_p") introduced it so that it could be used in commit fddd52012295 ("module_param: allow 'bool' module_params to be bool, not just int."); I am guessing that typecheck() could not be used in those cases. Perhaps all instances of typecheck() could be converted to __same_type()? Do you want me to send a formal patch for that diff? Cheers, Nathan