1 /* PR middle-end/78622 - [7 Regression] -Wformat-overflow/-fprintf-return-value
2 incorrect with overflow/wrapping
4 { dg-options "-Wformat-overflow=2" }
5 The h and hh length modifiers are a C99 feature (see PR 78959).
6 { dg-require-effective-target c99_runtime } */
10 int test_uchar_hhd (unsigned char x
)
12 if (x
< 64 || x
> 2U * __SCHAR_MAX__
- 10)
15 return __builtin_sprintf (buf
, "%hhd", x
+ 1); /* { dg-warning "directive writing between 1 and 4 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
18 int test_uint_hhd (unsigned x
)
20 if (x
< 64 || x
> 2U * __INT_MAX__
- 10)
23 return __builtin_sprintf (buf
, "%hhd", x
+ 1); /* { dg-warning "directive writing between 1 and 4 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
26 int test_schar_hhu (signed char x
)
31 return __builtin_sprintf (buf
, "%hhu", x
+ 1); /* { dg-warning "directive writing between 1 and 3 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
34 int test_ushort_hd (unsigned short x
)
36 if (x
< 64 || x
> 2U * __SHRT_MAX__
- 10)
39 return __builtin_sprintf (buf
, "%hd", x
+ 1); /* { dg-warning "directive writing between 1 and 6 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
42 int test_uint_d (unsigned x
)
44 if (x
< 64 || x
> 2U * __INT_MAX__
- 10)
47 return __builtin_sprintf (buf
, "%d", x
+ 1); /* { dg-warning "directive writing between 1 and 11 bytes into a region of size 1" "int32plus" { target { int32plus } } } */
50 int test_ulong_ld (unsigned long x
)
52 if (x
< 64 || x
> 2LU * __LONG_MAX__
- 10)
55 return __builtin_sprintf (buf
, "%ld", x
+ 1); /* { dg-warning "directive writing between 1 and 11 bytes into a region of size 1" "ilp32" { target { ilp32 } } } */
56 /* { dg-warning "directive writing between 1 and 20 bytes into a region of size 1" "lp64" { target { lp64 } } .-1 } */
59 int test_ullong_lld (unsigned long long x
)
61 if (x
< 64 || x
> 2LLU * __LONG_LONG_MAX__
- 10)
64 return __builtin_sprintf (buf
, "%lld", x
+ 1); /* { dg-warning "directive writing between 1 and 20 bytes into a region of size 1" "int32plus" { target { int32plus } } } */