| 1 |
/* |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-Wall" } */ |
| 4 |
|
| 5 |
typedef __SIZE_TYPE__ size_t; |
| 6 |
|
| 7 |
int memcmp (const void*, const void*, size_t); |
| 8 |
int strncmp (const char*, const char*, size_t); |
| 9 |
char* stpncpy (char*, const char*, size_t); |
| 10 |
char* strncpy (char*, const char*, size_t); |
| 11 |
|
| 12 |
extern char a4[4], b5[5]; |
| 13 |
|
| 14 |
struct A { char a4[4]; }; |
| 15 |
|
| 16 |
extern volatile int i; |
| 17 |
extern void* volatile ptr; |
| 18 |
|
| 19 |
void test_stpncpy (struct A *p) |
| 20 |
{ |
| 21 |
ptr = stpncpy (a4, b5, 4); |
| 22 |
ptr = stpncpy (a4, b5, 5); // { dg-warning "writing 5 bytes" } |
| 23 |
|
| 24 |
ptr = stpncpy (p->a4, b5, 4); |
| 25 |
ptr = stpncpy (p->a4, b5, 5); // { dg-warning "writing 5 bytes" } |
| 26 |
} |
| 27 |
|
| 28 |
void test_strncpy (struct A *p) |
| 29 |
{ |
| 30 |
ptr = strncpy (a4, b5, 4); |
| 31 |
ptr = strncpy (a4, b5, 5); // { dg-warning "writing 5 bytes" } |
| 32 |
|
| 33 |
ptr = strncpy (p->a4, b5, 4); |
| 34 |
ptr = strncpy (p->a4, b5, 5); // { dg-warning "writing 5 bytes" } |
| 35 |
} |