[Pkg-xfce-devel] Bug#811608: FTBFS with GCC 6: nonnull argument compared to NULL

Yves-Alexis Perez corsac at debian.org
Fri Jan 22 11:59:09 UTC 2016


On jeu., 2016-01-21 at 15:31 -0800, Martin Michlmayr wrote:
> * Yves-Alexis Perez <corsac at debian.org> [2016-01-20 08:25]:
> > > Note that only the first error is reported; there might be more.  You
> > > can find a snapshot of GCC 6 in experimental.  To build with GCC 6,
> > > you can set CC=gcc-6 CXX=g++-6 explicitly.
> > 
> > Could you add a bit more information about this, especially the new
> > options
> > etc?
> 
> You can find some of that here:
> https://gcc.gnu.org/gcc-6/changes.html

Thanks, but a quick search for null only reveals things about -Wnull-
dereference.
> 
> > > > glib-2.0 
> > > > libsystem.c: In function 'getpwnam':
> > > > libsystem.c:859:14: error: nonnull argument 'name' compared to NULL [-
> > > > Werror=nonnull]
> > > >       if (name == NULL)
> > 
> > This looks spurious. It's usually considered a *good* idea to check for
> > NULL
> > pointer, so I don't understand the error. Also, the code is:
> 
> I'm no expert with this, but /usr/include/pwd.h defines:
> extern struct passwd *getpwnam (const char *__name) __nonnull ((1));
> 
> Looking at the preprocessed source of libsystem I see this e.g.
> extern struct passwd *getpwnam (const char *__name) __attribute__
> ((__nonnull__ (1)));
> extern int __attribute__((__nonnull__ (1))) pam_end(pam_handle_t *pamh, int
> pam_status);
> 
> so it's marked as __nonnull__ but then you're checking if it's NULL,
> and this is what this warning is about (error because of -Werror).
> 
> You can find more info about this warning and the rationale here:
> https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00621.html

Well, I can't find any help there, but digging a bit more at https://gcc.gnu.o
rg/onlinedocs/gcc-5.3.0/gcc/Function-Attributes.html#index-
g_t_0040code_007bnonnull_007d-function-attribute-3192 there are more info
about nonnull
> 
> > So:
> > 
> > - I fail to see how the compiler can statically know name is NULL
> 
> Because of __nonnull__.

What I don't know if that this means *name is *guaranteed* to be non null (and
so we can safely remove the check) or if that means it the code needs to check
it beforehand (by the caller, for example).

Regards,
-- 
Yves-Alexis

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part
URL: <http://lists.alioth.debian.org/pipermail/pkg-xfce-devel/attachments/20160122/59130187/attachment.sig>


More information about the Pkg-xfce-devel mailing list