[Bug middle-end/88273] [8/9 Regression] warning: 'memcpy' offset [-527, -529] is out of the bounds [0, 16] of object 'vrsave' with type 'union <anonymous>' [-Warray-bounds]

mathieu.malaterre at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jan 2 21:50:00 GMT 2019


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

--- Comment #7 from Mathieu Malaterre <mathieu.malaterre at gmail dot com> ---
Here is the new creduced test case:

$ cat bug.c
#include <string.h>

typedef struct {
  int b[4]
} c;
void* d;
unsigned e;
inline int h(void *i, int p2, int j) {
  if (j < 0 || e < j) {
    int copy = ({
      typeof(e) k = j - e;
      k;
    });
    i += e - p2;
    memcpy(d, i, copy);
    e = copy;
  }
}
void a() {
  int g = h(&g, 0, sizeof(c));
  union {
    c f;
  } vrsave;
  h(&vrsave, 33 * sizeof(c), -1);
}


Compilation:

$ powerpc-linux-gnu-gcc -Warray-bounds -mcpu=powerpc -O2 -c bug.c

Using creduce with:

#!/bin/bash
powerpc-linux-gnu-gcc -Warray-bounds -mcpu=powerpc -O2 -c ptrace2.i >&
output.txt
grep error output.txt && exit 1
grep -F "warning: 'memcpy' offset [-527, -529] is out of the bounds [0, 16] of
object 'vrsave' with type 'union <anonymous>'" output.txt >/dev/null 2>&1


More information about the Gcc-bugs mailing list