All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nick Desaulniers <ndesaulniers@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: kernel test robot <lkp@intel.com>,
	Nathan Chancellor <nathan@kernel.org>,
	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
Date: Mon, 13 Sep 2021 10:00:02 -0700	[thread overview]
Message-ID: <CAKwvOdnGaVb1XGwYpNK_3zAEyZ0JC1SDjC1UzzFEH=d_Mdi7Fw@mail.gmail.com> (raw)
In-Reply-To: <20210913165317.GX2505917@nvidia.com>

On Mon, Sep 13, 2021 at 9:53 AM Jason Gunthorpe <jgg@nvidia.com> wrote:
>
> On Sat, Sep 11, 2021 at 08:17:08PM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   926de8c4326c14fcf35f1de142019043597a4fac
> > commit: 84f969e1c48ed3825986e91a0786e363d57f69d1 IB/qib: Fix null pointer subtraction compiler warning
> > date:   3 days ago
> > config: x86_64-randconfig-a014-20210911 (attached as .config)
> > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 261cbe98c38f8c1ee1a482fe76511110e790f58a)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=84f969e1c48ed3825986e91a0786e363d57f69d1
> >         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >         git fetch --no-tags linus master
> >         git checkout 84f969e1c48ed3825986e91a0786e363d57f69d1
> >         # save the attached .config to linux build tree
> >         mkdir build_dir
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=x86_64 SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All errors (new ones prefixed by >>):
> >
> > >> drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression
> >    QIB_DIAGC_ATTR(rc_resends);
> >    ^~~~~~~~~~~~~~~~~~~~~~~~~~
> >    drivers/infiniband/hw/qib/qib_sysfs.c:406:16: note: expanded from macro 'QIB_DIAGC_ATTR'
> >            static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);    \
> >            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
> >    #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> >                                     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
> >    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >                                                           ^~~~
> >    drivers/infiniband/hw/qib/qib_sysfs.c:413:1: note: cannot access field of null pointer
> >    drivers/infiniband/hw/qib/qib_sysfs.c:406:43: note: expanded from macro 'QIB_DIAGC_ATTR'
> >            static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);    \
> >                                                     ^
> >    drivers/infiniband/hw/qib/qib_sysfs.c:414:1: error: static_assert expression is not an integral constant expression
> >    QIB_DIAGC_ATTR(seq_naks);
> >    ^~~~~~~~~~~~~~~~~~~~~~~~
>
> Nick/Nathan
>
> Clang is being a real PITA here - do you know of a solution?

Hi Jason,
Thanks for wrestling with this.  We filed a quick thread last week to
track this:
https://github.com/ClangBuiltLinux/linux/issues/1452
With conferences this and next week, and -Werror fallout, there's a
lot of fire right now and not a lot of time to triage.

I guess I'm curious, what is the intent of what this code is trying to
do, and can this be replaced with BUILD_BUG_ON?

>
> 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?
-- 
Thanks,
~Nick Desaulniers

WARNING: multiple messages have this Message-ID (diff)
From: Nick Desaulniers <ndesaulniers@google.com>
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 10:00:02 -0700	[thread overview]
Message-ID: <CAKwvOdnGaVb1XGwYpNK_3zAEyZ0JC1SDjC1UzzFEH=d_Mdi7Fw@mail.gmail.com> (raw)
In-Reply-To: <20210913165317.GX2505917@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 3826 bytes --]

On Mon, Sep 13, 2021 at 9:53 AM Jason Gunthorpe <jgg@nvidia.com> wrote:
>
> On Sat, Sep 11, 2021 at 08:17:08PM +0800, kernel test robot wrote:
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> > head:   926de8c4326c14fcf35f1de142019043597a4fac
> > commit: 84f969e1c48ed3825986e91a0786e363d57f69d1 IB/qib: Fix null pointer subtraction compiler warning
> > date:   3 days ago
> > config: x86_64-randconfig-a014-20210911 (attached as .config)
> > compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 261cbe98c38f8c1ee1a482fe76511110e790f58a)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=84f969e1c48ed3825986e91a0786e363d57f69d1
> >         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >         git fetch --no-tags linus master
> >         git checkout 84f969e1c48ed3825986e91a0786e363d57f69d1
> >         # save the attached .config to linux build tree
> >         mkdir build_dir
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=x86_64 SHELL=/bin/bash
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All errors (new ones prefixed by >>):
> >
> > >> drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression
> >    QIB_DIAGC_ATTR(rc_resends);
> >    ^~~~~~~~~~~~~~~~~~~~~~~~~~
> >    drivers/infiniband/hw/qib/qib_sysfs.c:406:16: note: expanded from macro 'QIB_DIAGC_ATTR'
> >            static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);    \
> >            ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
> >    #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
> >                                     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
> >    #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
> >                                                           ^~~~
> >    drivers/infiniband/hw/qib/qib_sysfs.c:413:1: note: cannot access field of null pointer
> >    drivers/infiniband/hw/qib/qib_sysfs.c:406:43: note: expanded from macro 'QIB_DIAGC_ATTR'
> >            static_assert(&((struct qib_ibport *)0)->rvp.n_##N != (u64 *)NULL);    \
> >                                                     ^
> >    drivers/infiniband/hw/qib/qib_sysfs.c:414:1: error: static_assert expression is not an integral constant expression
> >    QIB_DIAGC_ATTR(seq_naks);
> >    ^~~~~~~~~~~~~~~~~~~~~~~~
>
> Nick/Nathan
>
> Clang is being a real PITA here - do you know of a solution?

Hi Jason,
Thanks for wrestling with this.  We filed a quick thread last week to
track this:
https://github.com/ClangBuiltLinux/linux/issues/1452
With conferences this and next week, and -Werror fallout, there's a
lot of fire right now and not a lot of time to triage.

I guess I'm curious, what is the intent of what this code is trying to
do, and can this be replaced with BUILD_BUG_ON?

>
> 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?
-- 
Thanks,
~Nick Desaulniers

  reply	other threads:[~2021-09-13 17:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-11 12:17 drivers/infiniband/hw/qib/qib_sysfs.c:413:1: error: static_assert expression is not an integral constant expression kernel test robot
2021-09-11 12:17 ` kernel test robot
2021-09-13 16:53 ` Jason Gunthorpe
2021-09-13 16:53   ` Jason Gunthorpe
2021-09-13 17:00   ` Nick Desaulniers [this message]
2021-09-13 17:00     ` Nick Desaulniers
2021-09-13 17:00     ` Nick Desaulniers
2021-09-13 18:38     ` Jason Gunthorpe
2021-09-13 18:38       ` Jason Gunthorpe
2021-09-13 18:53       ` Nathan Chancellor
2021-09-13 18:53         ` Nathan Chancellor
2021-09-13 19:02         ` Jason Gunthorpe
2021-09-13 19:02           ` Jason Gunthorpe
2021-09-13 19:13           ` Nathan Chancellor
2021-09-13 19:13             ` Nathan Chancellor
2021-09-13 19:16             ` Jason Gunthorpe
2021-09-13 19:16               ` Jason Gunthorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKwvOdnGaVb1XGwYpNK_3zAEyZ0JC1SDjC1UzzFEH=d_Mdi7Fw@mail.gmail.com' \
    --to=ndesaulniers@google.com \
    --cc=clang-built-linux@googlegroups.com \
    --cc=jgg@nvidia.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.