aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr104380.c
blob: 54b2a87cf4453987c744233cb0116e33bb854556 (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
31
32
/* PR target/104380 */
/* This test needs runtime that provides __*_chk functions.  */
/* { dg-do run { target *-*-linux* *-*-gnu* *-*-uclinux* } } */
/* { dg-options "-O2 -std=c99" } */

#define FORTIFY_SOURCE 2
#include <stdio.h>
#include <stdarg.h>

static char buf[4096];
static char gfmt[] = "%Lg";

static int __attribute__ ((noipa))
foo (char *str, const char *fmt, ...)
{
  int ret;
  va_list ap;
  va_start (ap, fmt);
  ret = vsnprintf (str, 4096, fmt, ap);
  va_end (ap);
  return ret;
}

int
main ()
{
  long double dval = 128.0L;
  int ret = foo (buf, gfmt, dval);
  if (ret != 3 || __builtin_strcmp (buf, "128") != 0)
    __builtin_abort ();
  return 0;
}