[Bug middle-end/99676] New: missing detail in warning for passing smaller array to bigger argument

msebor at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 19 22:22:16 GMT 2021


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

            Bug ID: 99676
           Summary: missing detail in warning for passing smaller array to
                    bigger argument
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The warning(s) below are confusing:
1) each mentions the argument type is 'int *' when it actually uses 'int[4]' to
trigger, and
2) it doesn't point to the declaration of the object or subobject whose size it
uses.
In cases like pr99673 the missing details make the warning harder than
necessary to understand and decide if it's a false positive.

$ cat x.c && gcc -O -S -Wall x.c
struct A { int a[2], b[2]; };

void f (int[4], int[4]);

void g (int *p, int *q)
{
  f (p, q);
}

void h (struct A *p)
{
  g (p->a, p->b);
}
In function ‘g’,
    inlined from ‘h’ at x.c:12:3:
x.c:7:3: warning: ‘f’ accessing 16 bytes in a region of size 8
[-Wstringop-overflow=]
    7 |   f (p, q);
      |   ^~~~~~~~
x.c: In function ‘h’:
x.c:7:3: note: referencing argument 1 of type ‘int *’
In function ‘g’,
    inlined from ‘h’ at x.c:12:3:
x.c:7:3: warning: ‘f’ accessing 16 bytes in a region of size 8
[-Wstringop-overflow=]
x.c: In function ‘h’:
x.c:7:3: note: referencing argument 2 of type ‘int *’
x.c:3:6: note: in a call to function ‘f’
    3 | void f (int[4], int[4]);
      |      ^


More information about the Gcc-bugs mailing list