[Bug tree-optimization/88771] New: [9 Regression] Misleading -Werror=array-bounds error

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 9 13:37:00 GMT 2019


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

            Bug ID: 88771
           Summary: [9 Regression] Misleading -Werror=array-bounds error
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

Starting from r264956 I see error for:

$ cat om.i
typedef struct {
  int a;
} * b;

char *c, *x;
int f;

void d() {
  b e;
  char a = f + 1 ?: f;
  __builtin_strncpy(c, x, f);
  if (a)
    e->a = 0;
}

$ gcc  om.i -c -O2 -Werror=array-bounds
om.i: In function ‘d’:
om.i:11:3: error: ‘__builtin_strncpy’ pointer overflow between offset 0 and
size [-1, 9223372036854775807] [-Werror=array-bounds]
   11 |   __builtin_strncpy(c, x, f);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

$ gcc  om.i -c -O2 -Werror=array-bounds -m32
om.i: In function ‘d’:
om.i:11:3: error: ‘__builtin_strncpy’ pointer overflow between offset 0 and
size [4294967295, 2147483647] [-Werror=array-bounds]
   11 |   __builtin_strncpy(c, x, f);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


More information about the Gcc-bugs mailing list