public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug build/26686] New: -Warray-parameter instances building with GCC 11
Date: Thu, 01 Oct 2020 00:19:54 +0000	[thread overview]
Message-ID: <bug-26686-131@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2020-10-01  0:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-01  0:19 msebor at gmail dot com [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-26686-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).