Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp265535pxb; Mon, 13 Sep 2021 18:50:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx813umlzKhHP+ZcuIeZE/OW5wnL0LIqR6YqgNZ00Y4I/HrXQ3MFSF85xvYpG9kfee9M2Rr X-Received: by 2002:a17:906:3486:: with SMTP id g6mr16643619ejb.71.1631584233992; Mon, 13 Sep 2021 18:50:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631584233; cv=none; d=google.com; s=arc-20160816; b=HfiAvEk9JbQcxVZAQ+n2rEKxJ3nMF9l6MZVVNjSXBfHxA3JyJ7y08ZdftYbqAPX+zx NyOIQUspWvRPi4TC65/EiNP9DS221l8RV7ewh6vLNPsiyfF5dxTgfCzqk8jVIB5b/1ms RewhlVSO9xu8TQHuGZo3lQZab0V0FG58jB+XwWdQ5n/RvpJYA0XRlk2cTUE+8YDd7Mwh +rFn49FEKRAZWwxg/1fXDj19HHKcBXV7nasfxAh36Mm4YDZUFyrodSWLSgKpFg+fEiJ0 oolZk9nYYQ6un6Sf20ZSA/Gth3D9KKJpZsu5Hfe4ka4TJfKZG/AILeF5rwQ+KxAYEfSh x6oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NwDwsNo2dbqpkhp3E4dpbXh8nezZwNUJL7MJaXnPsFQ=; b=LPpVpHpi2KhxdJal6Kj/q/OJ7xiNAn1UjelfwM1Ez+czFiAHDzHtMyrDhMn2gThNRU LxMRw8xr6az105vzuAq0DOgU26MZuRdMlENSRntYVmdgvU+lNMV1HstK9Y7hkk/TJsrB 29apQFaiP1SDTpL07cyNKGXXMKaHuITdPW3R5r4IlsH4R/GsODlUe3HgyZJIkbv/jtpP kf8TJIRH9NA+Db6VbBFEOjd6ILrJQzMbREpn3pA2hFMpa81UO2rrYkVWycQZczRAbgED MZurGF3++HmnJGURBA/Hi7+I8dpaAcjIGn3yv6Bntg9sYpu39YFs1XKacBsuzQpByfC4 NfIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=praELURU; 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 h15si8930443ede.550.2021.09.13.18.50.10; Mon, 13 Sep 2021 18:50:33 -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=praELURU; 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 S241907AbhIMSyy (ORCPT + 99 others); Mon, 13 Sep 2021 14:54:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:37082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347499AbhIMSyu (ORCPT ); Mon, 13 Sep 2021 14:54:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E652860F24; Mon, 13 Sep 2021 18:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631559214; bh=YILugTkzyXwATz0qqlrum5V7nKWX1bT+knVxHyNOA9c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=praELURUY/GLHNH2qLYD3tZceMheOY18RPQhQiMQCPjfVZpsmnneQtHS5FNI6TXH4 etPVoeAjdqozGMclhnHW2ljAb7IAAgVcC7aW5TIn/3K5iob65roL3Y5n6AOx+vSG+F v7QKVlxfrh9lw7uS6bvfxMWsTyM4PK7I+jMxmtB/L5Vi3rgRfKIEXs9xepn6EJInGL xcVuQZya4J0GO7Ve6u7kC65oHBNKUe65vf79hYmBOWkpXWr2zEoi28Fo96+XGOfuJr xGzSKIhkdo5ZItryKc5xNjcZcCjIQB7KRgrmsqKvnsa7yH20asN2JMqHaKVf6B89dN El52q5qXVbFPg== Date: Mon, 13 Sep 2021 11:53:25 -0700 From: Nathan Chancellor 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 Subject: Re: drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression Message-ID: References: <202109112002.NZceUwiC-lkp@intel.com> <20210913165317.GX2505917@nvidia.com> <20210913183813.GY2505917@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210913183813.GY2505917@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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'. Cheers, Nathan diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c index 452e2355d24e..0a3b28142c05 100644 --- a/drivers/infiniband/hw/qib/qib_sysfs.c +++ b/drivers/infiniband/hw/qib/qib_sysfs.c @@ -403,7 +403,7 @@ static ssize_t diagc_attr_store(struct ib_device *ibdev, u32 port_num, } #define QIB_DIAGC_ATTR(N) \ - static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL); \ + static_assert(__same_type(((struct qib_ibport *)0)->rvp.n_##N, u64)); \ static struct qib_diagc_attr qib_diagc_attr_##N = { \ .attr = __ATTR(N, 0664, diagc_attr_show, diagc_attr_store), \ .counter = \