aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/pr103961.c
blob: 2cd52884e3bfdb81bd41da5e33f94073cfcef0ce (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
/* { dg-do compile } */
/* { dg-options "-O2" } */

extern void abort ();

extern inline __attribute__ ((__gnu_inline__)) int
sprintf (char *restrict s, const char *restrict fmt, ...)
{
  return __builtin___sprintf_chk (s, 1, __builtin_object_size (s, 1),
				  fmt, __builtin_va_arg_pack ());
}

void
cap_to_text (int c)
{
  char buf[1572];
  char *p;
  int n, t;
  p = 20 + buf;
  for (t = 8; t--; )
    {
      for (n = 0; n < c; n++)
	p += sprintf (p, "a,");
      p--;
      if (__builtin_object_size (p, 1) == 0)
	abort ();
    }
}

/* { dg-final { scan-assembler-not "abort" } } */