1 | #define _GNU_SOURCE 1 |
2 | #include <wchar.h> |
3 | #include <stdio.h> |
4 | #include <string.h> |
5 | #include <wctype.h> |
6 | #include <libc-diag.h> |
7 | |
8 | static int |
9 | do_test (void) |
10 | { |
11 | int result = 0; |
12 | char buf[100]; |
13 | wchar_t tmp[3]; |
14 | tmp[0] = '8'; |
15 | tmp[1] = '1'; |
16 | tmp[2] = 0; |
17 | |
18 | /* GCC does not know the result of wcstof so cannot see that the |
19 | snprintf output is not truncated. */ |
20 | DIAG_PUSH_NEEDS_COMMENT; |
21 | #if __GNUC_PREREQ (7, 0) |
22 | DIAG_IGNORE_NEEDS_COMMENT (7.0, "-Wformat-truncation" ); |
23 | #endif |
24 | snprintf (s: buf, maxlen: 100, format: "%S = %f" , tmp, wcstof (tmp, NULL)); |
25 | DIAG_POP_NEEDS_COMMENT; |
26 | printf (format: "\"%s\" -> %s\n" , buf, |
27 | strcmp (buf, "81 = 81.000000" ) == 0 ? "okay" : "buggy" ); |
28 | result |= strcmp (buf, "81 = 81.000000" ) != 0; |
29 | |
30 | return result; |
31 | } |
32 | |
33 | #include <support/test-driver.c> |
34 | |