public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug build/26686] New: -Warray-parameter instances building with GCC 11
@ 2020-10-01  0:19 msebor at gmail dot com
  2020-10-05 15:35 ` [Bug build/26686] " msebor at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: msebor at gmail dot com @ 2020-10-01  0:19 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=26686

            Bug ID: 26686
           Summary: -Warray-parameter instances building with GCC 11
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: build
          Assignee: unassigned at sourceware dot org
          Reporter: msebor at gmail dot com
                CC: carlos at redhat dot com
  Target Milestone: ---

GCC 11 has recently gained a couple of new options designed to help improve the
consistency of the forms of array and VLA paremeters between redeclarations of
the same function, detect likely incompatible forms of VLA parameters, and help
detect out of bounds accesses to such arguments.  The options are
-Warray-parameter and -Wvla-parameter.

A Glibc build with the latest GCC shows the following instances of the former. 
All appear to be by design and can be avoided simply by consistently declaring
the functions with the same array form (I recommend using the constant bound
since GCC uses it to detect out-of-bounds accesses in calls to the functions as
well as by the function bodies).

netname.c:32:20: warning: argument 1 of type ‘char[256]’ with mismatched bound
[-Warray-parameter=]
   32 | user2netname (char netname[MAXNETNAMELEN + 1], const uid_t uid,
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/rpc/auth.h:2,
                 from ../sunrpc/rpc/rpc.h:45,
                 from ../include/rpc/rpc.h:2,
                 from netname.c:22:
../sunrpc/rpc/auth.h:184:26: note: previously declared as ‘char *’
  184 | extern int user2netname (char *, const uid_t, const char *) __THROW;
      |                          ^~~~~~
netname.c:61:20: warning: argument 1 of type ‘char[256]’ with mismatched bound
[-Warray-parameter=]
   61 | host2netname (char netname[MAXNETNAMELEN + 1], const char *host,
      |               ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/rpc/auth.h:2,
                 from ../sunrpc/rpc/rpc.h:45,
                 from ../include/rpc/rpc.h:2,
                 from netname.c:22:
../sunrpc/rpc/auth.h:183:26: note: previously declared as ‘char *’
  183 | extern int host2netname (char *, const char *, const char *) __THROW;
      |                          ^~~~~~
netname.c:126:18: warning: argument 1 of type ‘char[256]’ with mismatched bound
[-Warray-parameter=]
  126 | getnetname (char name[MAXNETNAMELEN + 1])
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/rpc/auth.h:2,
                 from ../sunrpc/rpc/rpc.h:45,
                 from ../include/rpc/rpc.h:2,
                 from netname.c:22:
../sunrpc/rpc/auth.h:182:24: note: previously declared as ‘char *’
  182 | extern int getnetname (char *) __THROW;
      |                        ^~~~~~
netname.c:145:26: warning: argument 1 of type ‘const char[256]’ with mismatched
bound [-Warray-parameter=]
  145 | netname2user (const char netname[MAXNETNAMELEN + 1], uid_t * uidp,
gid_t * gidp,
      |               ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/rpc/auth.h:2,
                 from ../sunrpc/rpc/rpc.h:45,
                 from ../include/rpc/rpc.h:2,
                 from netname.c:22:
../sunrpc/rpc/auth.h:185:26: note: previously declared as ‘const char *’
  185 | extern int netname2user (const char *, uid_t *, gid_t *, int *, gid_t
*)
      |                          ^~~~~~~~~~~~
netname.c:192:26: warning: argument 1 of type ‘const char[256]’ with mismatched
bound [-Warray-parameter=]
  192 | netname2host (const char netname[MAXNETNAMELEN + 1], char *hostname,
      |               ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../include/rpc/auth.h:2,
                 from ../sunrpc/rpc/rpc.h:45,
                 from ../include/rpc/rpc.h:2,
                 from netname.c:22:
../sunrpc/rpc/auth.h:187:26: note: previously declared as ‘const char *’
  187 | extern int netname2host (const char *, char *, const int) __THROW;
      |                          ^~~~~~~~~~~~
fetch-value.c:143:27: warning: argument 2 of type ‘uint32_t[2]’ {aka ‘unsigned
int[2]’} with mismatched bound [-Warray-parameter=]
  143 |                  uint32_t desc[2], int descriptor_name, psaddr_t idx,
      |                  ~~~~~~~~~^~~~~~~
In file included from fetch-value.c:19:
thread_dbP.h:238:44: note: previously declared as ‘uint32_t[3]’ {aka ‘unsigned
int[3]’}
  238 |                                  db_desc_t field, int descriptor_name,
      |                                  ~~~~~~~~~~^~~~~
fetch-value.c:243:33: warning: argument 2 of type ‘uint32_t[2]’ {aka ‘unsigned
int[2]’} with mismatched bound [-Warray-parameter=]
  243 |                        uint32_t desc[2], int descriptor_name, psaddr_t
idx,
      |                        ~~~~~~~~~^~~~~~~
In file included from fetch-value.c:19:
thread_dbP.h:242:50: note: previously declared as ‘uint32_t[3]’ {aka ‘unsigned
int[3]’}
  242 |                                        db_desc_t field, int
descriptor_name,
      |                                        ~~~~~~~~~~^~~~~

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-29 17:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  0:19 [Bug build/26686] New: -Warray-parameter instances building with GCC 11 msebor at gmail dot com
2020-10-05 15:35 ` [Bug build/26686] " msebor at gmail dot com
2020-10-05 16:49 ` joseph at codesourcery dot com
2020-10-05 21:46 ` msebor at gmail dot com
2020-10-29 17:45 ` jsm28 at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).