| 1 |
/* PR target/104380 */ |
| 2 |
/* This test needs runtime that provides __*_chk functions. */ |
| 3 |
/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */ |
| 4 |
/* { dg-options "-O2 -std=c99" } */ |
| 5 |
|
| 6 |
#define FORTIFY_SOURCE 2 |
| 7 |
#include <stdio.h> |
| 8 |
#include <stdarg.h> |
| 9 |
|
| 10 |
static char buf[4096]; |
| 11 |
static char gfmt[] = "%Lg"; |
| 12 |
|
| 13 |
static int __attribute__ ((noipa)) |
| 14 |
foo (char *str, const char *fmt, ...) |
| 15 |
{ |
| 16 |
int ret; |
| 17 |
va_list ap; |
| 18 |
va_start (ap, fmt); |
| 19 |
ret = vsnprintf (str, 4096, fmt, ap); |
| 20 |
va_end (ap); |
| 21 |
return ret; |
| 22 |
} |
| 23 |
|
| 24 |
int |
| 25 |
main () |
| 26 |
{ |
| 27 |
long double dval = 128.0L; |
| 28 |
int ret = foo (buf, gfmt, dval); |
| 29 |
if (ret != 3 || __builtin_strcmp (buf, "128") != 0) |
| 30 |
__builtin_abort (); |
| 31 |
return 0; |
| 32 |
} |