1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wformat-overflow" } */
3 
4 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
sprintf(char * __restrict __s,const char * __restrict __fmt,...)5 __attribute__ ((__nothrow__ , __leaf__)) sprintf (char *__restrict __s, const char *__restrict __fmt, ...)
6 {
7   return __builtin___sprintf_chk (__s, 2 - 1,
8 				  __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ());
9 }
10 char number[sizeof "999999"];
11 int somerandom (void);
12 void
Foo(void)13 Foo (void)
14 {
15   int i = somerandom ();
16   if (! (0 <= i))
17     __builtin_unreachable ();
18   if (! (0 <= i && i <= 999999))
19     __builtin_unreachable ();
20   /* The correctness bits for [E]VRP cannot handle chained conditionals
21      when deciding to ignore a unreachable branch for setting SSA range info. */
22   sprintf (number, "%d", i); /* { dg-bogus "writing" "" { xfail *-*-* } } */
23 }
24