public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sandra at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/113515] New: Wrong documentation for -Wstringop-overflow
Date: Sat, 20 Jan 2024 01:42:18 +0000	[thread overview]
Message-ID: <bug-113515-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113515
           Summary: Wrong documentation for -Wstringop-overflow
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sandra at gcc dot gnu.org
  Target Milestone: ---

This is essentially the example for -Warray-parameter=1 in the manual (see
PR102998):

#include <stdlib.h>

void f (int[static 4]);
void f (int[]);  // warning 1

void g (void)
{
  int *p = (int *) malloc (1 * sizeof(int));
  f (p);   // warning 2
}

Warning 2 is:

example.c: In function 'g':
example.c:9:3: warning: 'f' accessing 16 bytes in a region of size 4
[-Wstringop-overflow=]
    9 |   f (p);
      |   ^~~~~
example.c:9:3: note: referencing argument 1 of type 'int[4]'
example.c:4:6: note: in a call to function 'f'
    4 | void f (int[]);
      |      ^

It's correct to warn here, but the manual is not helpful in explaining what
-Wstringop-overflow has to do with it.

The documentation for -Wstringop-overflow says:

Warn for calls to string manipulation functions such as @code{memcpy} and
@code{strcpy} that are determined to overflow the destination buffer.

There are no string manipulation functions in this example.  I presume
additional kinds of object-size checking, beyond calls to string/byte array
manipulation functions from the standard library, were overloaded onto this
option without updating its description.  Can we get a better summary of what
it does now?

                 reply	other threads:[~2024-01-20  1:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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-113515-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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).