The 09/21/2020 12:45, Martin Sebor via Gcc-patches wrote:
> On 9/21/20 12:20 PM, Vaseeharan Vinayagamoorthy wrote:
> > After this patch, I am seeing this -Warray-parameter error:
> > 
> > In file included from ../include/pthread.h:1,
> >                   from ../sysdeps/nptl/thread_db.h:25,
> >                   from ../nptl/descr.h:32,
> >                   from ../sysdeps/aarch64/nptl/tls.h:44,
> >                   from ../include/errno.h:25,
> >                   from ../sysdeps/unix/sysv/linux/sysdep.h:23,
> >                   from ../sysdeps/unix/sysv/linux/generic/sysdep.h:22,
> >                   from ../sysdeps/unix/sysv/linux/aarch64/sysdep.h:24,
> >                   from <stdin>:1:
> > ../sysdeps/nptl/pthread.h:734:47: error: argument 1 of type ‘struct 
> > __jmp_buf_tag *’ declared as a pointer [-Werror=array-parameter=]
> >    734 | extern int __sigsetjmp (struct __jmp_buf_tag *__env, int 
> > __savemask) __THROWNL;
> >        |                         ~~~~~~~~~~~~~~~~~~~~~~^~~~~
> > In file included from ../include/setjmp.h:2,
> >                   from ../nptl/descr.h:24,
> >                   from ../sysdeps/aarch64/nptl/tls.h:44,
> >                   from ../include/errno.h:25,
> >                   from ../sysdeps/unix/sysv/linux/sysdep.h:23,
> >                   from ../sysdeps/unix/sysv/linux/generic/sysdep.h:22,
> >                   from ../sysdeps/unix/sysv/linux/aarch64/sysdep.h:24,
> >                   from <stdin>:1:
> > ../setjmp/setjmp.h:54:46: note: previously declared as an array ‘struct 
> > __jmp_buf_tag[1]’
> >     54 | extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int 
> > __savemask) __THROWNL;
> >        |                         ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
> > cc1: all warnings being treated as errors
> 
> The warning flags differences between the forms of array parameters
> in redeclarations of the same function, including pointers vs arrays
> as in this instance.  It needs to be suppressed in glibc, either by
> making the function declarations consistent, or by #pragma diagnostic.
> (IIRC, the pointer declaration comes before struct __jmp_buf_tag has
> been defined so simply using the array form there doesn't work without
> defining the type first.)
> 
> I would expect the warning to be suppressed when using the installed
> library thanks to -Wno-system-headers.

why is this a warning? i'm not convinced it
should be in -Wall.

this is a warning with false positives that
have no portable workaround and does not
really help catching bugs (at least i doubt
inconsistent array vs pointer declaration
is causing common problems).

what gcc should warn about is if there is an
array style argument declaration and a caller
passes an array that's provably shorter than
that.

pointer style declaration should be possible
to mix with array style (this is important
for standard headers but any api with multiple
implementations can end up in situations where
both array and pointer style decl will be
present).

Reply via email to