]>
Commit | Line | Data |
---|---|---|
55c14926 UD |
1 | #define _GNU_SOURCE 1 |
2 | #include <wchar.h> | |
3 | #include <stdio.h> | |
4 | #include <string.h> | |
5 | #include <wctype.h> | |
e15f7de6 | 6 | #include <libc-diag.h> |
55c14926 | 7 | |
29955b5d AS |
8 | static int |
9 | do_test (void) | |
55c14926 UD |
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 | ||
3c937826 JM |
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 | |
55c14926 | 24 | snprintf (buf, 100, "%S = %f", tmp, wcstof (tmp, NULL)); |
3c937826 | 25 | DIAG_POP_NEEDS_COMMENT; |
55c14926 UD |
26 | printf ("\"%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 | } | |
29955b5d | 32 | |
b2b1ea8b | 33 | #include <support/test-driver.c> |