From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E328F3FC3 for ; Mon, 13 Sep 2021 18:53:35 +0000 (UTC) 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> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210913183813.GY2505917@nvidia.com> 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 = \ From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============8100154542825417834==" MIME-Version: 1.0 From: Nathan Chancellor To: kbuild-all@lists.01.org Subject: Re: drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression Date: Mon, 13 Sep 2021 11:53:25 -0700 Message-ID: In-Reply-To: <20210913183813.GY2505917@nvidia.com> List-Id: --===============8100154542825417834== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 !=3D (u64 *)NULL); \ + static_assert(__same_type(((struct qib_ibport *)0)->rvp.n_##N, u64)); \ static struct qib_diagc_attr qib_diagc_attr_##N =3D { \ .attr =3D __ATTR(N, 0664, diagc_attr_show, diagc_attr_store), \ .counter =3D \ --===============8100154542825417834==--