Building with recent GCC versions: gdbsupport/gdb_assert.h:35:4: error: 'nonnull' argument 'filename' compared to NULL [-Werror=nonnull-compare]

Jan-Benedict Glaw jbglaw@lug-owl.de
Mon Jul 19 15:44:56 GMT 2021


Hi Alan,

On Sat, 2021-07-17 10:40:44 +0930, Alan Modra <amodra@gmail.com> wrote:
> On Sat, Jul 17, 2021 at 12:53:25AM +0200, Jan-Benedict Glaw wrote:
> > I noticed that when building GDB with a quite recent gcc (ie. "gcc
> 
> Wrong mailing list?

Maybe not: I asked on gcc-patches about this build issue, Martin Sebor
(who implemented the patch causing the breakage) answered to this (cf.
https://gcc.gnu.org/pipermail/gcc-patches/2021-July/575568.html).

Quoting:
===================== 8< ---------------------------------------------
> Code is this:
> 
>   31 class unlinker
>   32 {
>   33  public:
>   34
>   35   unlinker (const char *filename) ATTRIBUTE_NONNULL (2)
>   36     : m_filename (filename)
>   37   {
>   38     gdb_assert (filename != NULL);
>   39   }
> 
> I'm quite undecided whether this is bad behavior of GCC or bad coding
> style in Binutils/GDB, or both.

A warning should be expected in this case.  Before the recent GCC
change it was inadvertently suppressed in gdb_assert macros by its
operand being enclosed in parentheses.
----------------------------- >8 ====================================

Thanks,
  Jan-Benedict

-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20210719/bf76574a/attachment.sig>


More information about the Binutils mailing list