| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-O2" } |
| 3 |
|
| 4 |
void baz (int *, int *); |
| 5 |
|
| 6 |
#define MEMCPY(d,s,l) __builtin___memcpy_chk (d, s, l, __builtin_object_size (d, 0)) // { dg-warning "writing" } |
| 7 |
|
| 8 |
void |
| 9 |
foo () |
| 10 |
{ |
| 11 |
int *p = new int; |
| 12 |
int *q = new int[4]; |
| 13 |
MEMCPY (p, "abcdefghijklmnopqrstuvwxyz", sizeof (int)); |
| 14 |
MEMCPY (q, "abcdefghijklmnopqrstuvwxyz", 4 * sizeof (int)); |
| 15 |
baz (p, q); |
| 16 |
} |
| 17 |
|
| 18 |
void |
| 19 |
bar () |
| 20 |
{ |
| 21 |
int *p = new int; |
| 22 |
int *q = new int[4]; |
| 23 |
MEMCPY (p, "abcdefghijklmnopqrstuvwxyz", sizeof (int) + 1); // { dg-message "in expansion of macro" } |
| 24 |
MEMCPY (q, "abcdefghijklmnopqrstuvwxyz", 4 * sizeof (int) + 1); // { dg-message "in expansion of macro" } |
| 25 |
baz (p, q); |
| 26 |
} |