1 /* { dg-do compile } */
2 /* { dg-options "-O2" } */
3
4 typedef __SIZE_TYPE__ size_t;
5 extern void __chk_fail (void);
6 extern int snprintf (char *, size_t, const char *, ...);
snprintf(char * a,size_t b,const char * fmt,...)7 extern inline __attribute__((gnu_inline, always_inline)) int snprintf (char *a, size_t b, const char *fmt, ...)
8 {
9 if (__builtin_object_size (a, 0) != -1UL && __builtin_object_size (a, 0) < b)
10 __chk_fail ();
11 return __builtin_snprintf (a, b, fmt, __builtin_va_arg_pack ());
12 }
13 extern int snprintf (char *, size_t, const char *, ...) __asm ("mysnprintf");
14
15 char buf[10];
16
17 int
main(void)18 main (void)
19 {
20 snprintf (buf, 10, "%d%d\n", 10, 10);
21 return 0;
22 }
23
24 /* { dg-final { scan-assembler "mysnprintf" } } */
25 /* { dg-final { scan-assembler-not "__chk_fail" } } */
26