| 1 |
/* PR tree-optimization/87034 - missing -Wformat-overflow on a sprintf |
| 2 |
%s with a wide string. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-require-effective-target 4byte_wchar_t } */ |
| 5 |
/* { dg-options "-O2 -Wall -Wformat-overflow -ftrack-macro-expansion=0" } */ |
| 6 |
|
| 7 |
typedef __WCHAR_TYPE__ wchar_t; |
| 8 |
|
| 9 |
extern int sprintf (char*, const char*, ...); |
| 10 |
|
| 11 |
struct S |
| 12 |
{ |
| 13 |
char a[1]; |
| 14 |
void (*pf)(void); |
| 15 |
}; |
| 16 |
|
| 17 |
void test (struct S *p) |
| 18 |
{ |
| 19 |
const char *q = sizeof (wchar_t) == 2 |
| 20 |
? (char*)L"\x4142\x4344" : (char*)L"\x41424344\x45464748"; |
| 21 |
|
| 22 |
sprintf (p->a, "%s", q); /* { dg-warning "\\\[-Wformat-overflow" "pr87034" { xfail *-*-*} } */ |
| 23 |
} |