[Bug c/99420] New: New warning -Warray-parameter

raj.khem at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Mar 5 20:06:35 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99420

            Bug ID: 99420
           Summary: New warning -Warray-parameter
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: raj.khem at gmail dot com
  Target Milestone: ---

Following code (reduced from nss ) exhibits new warning with gcc11 on x86_64,
this doe s not happen when both these externs are in one function e.g. foo(),
its an expansion of PR_STATIC_ASSERT from nspr headers 

#define PR_STATIC_ASSERT(condition) \
    extern void pr_static_assert(int arg[(condition) ? 1 : -1])

my gcc version is

gcc version 11.0.1 20210303 (experimental) (GCC) 

a.c
==========================
void foo()
{
    unsigned char bytes[(440 / 8) * 2];
    extern void pr_static_assert(int arg[(sizeof(bytes) >= 32) ? 1 : -1]);
}
void bar()
{
    extern void pr_static_assert(int arg[(((long unsigned int)-1) > (long
unsigned int)1) ? 1 : -1]);
}

===========================

$ x86_64-yoe-linux-musl-gcc -c a.c -Werror=array-parameter=2

a.c: In function 'bar':
a.c:8:38: error: argument 1 of type 'int[1]' with mismatched bound
[-Werror=array-parameter=]
    8 |     extern void pr_static_assert(int arg[(((long unsigned int)-1) >
(long unsigned int)1) ? 1 : -1]);
      |                                 
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.c:4:38: note: previously declared as 'int *'
    4 |     extern void pr_static_assert(int arg[(sizeof(bytes) >= 32) ? 1 :
-1]);
      |                                 
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


More information about the Gcc-bugs mailing list