summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/Warray-bounds-38.c
blob: c9aa0eb8175d8e6a68dd557a465d68630a40becd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* PR middle-end/88273 - bogus warning: 'memcpy' offset [-527, -529]
   is out of the bounds [0, 16]
   { dg-do compile }
   { dg-options "-O2 -Wall" }  */

typedef __SIZE_TYPE__ size_t;

void *q;

size_t x, y;

inline void f (char *p, int i, size_t j)
{
  size_t n = y ? y : j;

  p += x - i;

  __builtin_memcpy (q, p, n);   /* { dg-bogus "bounds" } */

  x = n;
}

void g (void)
{
  struct { char a[16]; } s;

  f (q, 0, sizeof s);

  f (s.a, 33 * sizeof s, 1);
}