public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/113515] New: Wrong documentation for -Wstringop-overflow
@ 2024-01-20  1:42 sandra at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: sandra at gcc dot gnu.org @ 2024-01-20  1:42 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-20  1:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-20  1:42 [Bug c/113515] New: Wrong documentation for -Wstringop-overflow sandra 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).