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

            Bug ID: 100571
           Summary: bogus -Wstringop-overflow with VLA of elements larger
                    than byte
           Product: gcc
           Version: 10.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

This is probably a duplicate of an existing bug already fixed in GCC 11 but not
in GCC 10.  A recent enhancement to Glibc to add attribute access to a bunch of
APIs has triggered a couple of false positives in the test suite, including:
  https://sourceware.org/pipermail/libc-alpha/2021-May/125987.html
and
  https://sourceware.org/pipermail/libc-alpha/2021-May/126250.html

A simple test case for the problem is as follows:

$ cat t.c && gcc -O2 -S -Wall t.c
__attribute__ ((access (read_only, 1, 2))) void f (int *, int);

__SIZE_TYPE__ n;

void g (void)
{
  int a[n];
  a[0] = 0;
  f (a, n);
}
t.t: In function 'g':
t.c:9:3: warning: 'f' specified size 18446744073709551615 exceeds maximum
object size 9223372036854775807 [-Wstringop-overflow=]
    9 |   f (a, n);
      |   ^~~~~~~~
t.t:1:49: note: in a call to function 'f' declared with attribute 'read_only
(1, 2)'
    1 | __attribute__ ((access (read_only, 1, 2))) void f (int *, int);
      |                                                 ^

Reply via email to