math: Fix INFINITY and NAN on FreeBSD and AIX.
[gnulib.git] / doc / posix-functions / vsprintf.texi
blob688880a48a9314bbbeac0e2d50b351693939baa2
1 @node vsprintf
2 @subsection @code{vsprintf}
3 @findex vsprintf
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/vsprintf.html}
7 Gnulib module: vsprintf-posix or vsprintf-gnu
9 Portability problems fixed by either Gnulib module @code{vsprintf-posix} or @code{vsprintf-gnu}:
10 @itemize
11 @item
12 This function does not support size specifiers as in C99 (@code{hh}, @code{ll},
13 @code{j}, @code{t}, @code{z}) on some platforms:
14 AIX 5.1, HP-UX 11.23, Solaris 9, Cygwin 1.5.24, old mingw, MSVC 9.
15 @item
16 This function does not support size specifiers as in C23 (@code{w8},
17 @code{w16}, @code{w32}, @code{w64}, @code{wf8}, @code{wf16}, @code{wf32},
18 @code{wf64}) on some platforms:
19 glibc 2.37, musl libc, macOS 14, FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC, Android 9.0.
20 @item
21 printf of @samp{long double} numbers is unsupported on some platforms:
22 mingw, MSVC 14.
23 @item
24 printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an
25 incorrect result on some platforms:
26 AIX 7.3, Solaris 11.4, mingw, MSVC 14.
27 @item
28 This function does not support the @samp{a} and @samp{A} directives on some
29 platforms:
30 FreeBSD 5.2.1, OpenBSD 4.0, AIX 5.2, HP-UX 11,
31 Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
32 @item
33 This function does not support the @samp{b} directive, required by ISO C23,
34 on some platforms:
35 glibc 2.34, musl libc, macOS 14, FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5,
36 AIX 7.3, HP-UX 11, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC 14, Android 9.0.
37 @item
38 This function does not support the @samp{F} directive on some platforms:
39 NetBSD 3.0, AIX 5.1, HP-UX 11.23, Solaris 9,
40 Cygwin 1.5.x, mingw, MSVC 14.
41 @item
42 This function does not support the @samp{ls} directive on some platforms:
43 OpenBSD 4.0, Cygwin 1.5.x, Haiku.
44 @item
45 This function does not support precisions in the @samp{ls} directive correctly
46 on some platforms:
47 Solaris 11.4.
48 @item
49 This function does not support format directives that access arguments in an
50 arbitrary order, such as @code{"%2$s"}, on some platforms:
51 NetBSD 3.0, mingw, MSVC 14.
52 @item
53 This function doesn't support the @code{'} flag on some platforms:
54 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 14.
55 @item
56 This function does not round the argument of the @samp{a} directive correctly
57 on some platforms:
58 macOS 14, FreeBSD 14.0, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4.
59 @item
60 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
61 with zeroes, or wrong capitalization) on some platforms:
62 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 7.3, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC/clang.
63 @item
64 printf @code{"%#.0x"} or @code{"%#.0X"} with a zero argument yields an
65 incorrect result (non-empty) on some platforms:
66 Mac OS X 10.6.
67 @item
68 This function does not support precisions larger than 512 or 1024 in integer,
69 floating-point and pointer output on some platforms:
70 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
71 @item
72 This function mishandles large floating point precisions
73 (for example, formatting 1.0 with @samp{"%.511f"})
74 on some platforms:
75 Solaris 10.
76 @item
77 This function produces wrong output for the @samp{lc} directive with a NUL
78 wide character argument on some platforms:
79 musl libc 1.2.4.
80 @item
81 This function can crash in out-of-memory conditions on some platforms:
82 FreeBSD 14.0, NetBSD 5.0.
83 @item
84 The compiler warns that this function is deprecated:
85 macOS 14.
86 @end itemize
88 Portability problems fixed by Gnulib module @code{vsprintf-gnu}:
89 @itemize
90 @item
91 This function does not support the @samp{B} directive on some platforms:
92 glibc 2.34, musl libc, macOS 14, FreeBSD 13.2, NetBSD 10.0, OpenBSD 7.5, AIX 7.3, Solaris 11.4, Cygwin 3.5.3, mingw, MSVC, Android 9.0.
93 @end itemize
95 Portability problems fixed by either Gnulib module @code{vsprintf-posix} or @code{vsprintf-gnu}
96 and additionally the Gnulib module @code{printf-with-n-directive}:
97 @itemize
98 @item
99 This function does not support the @samp{n} directive on some platforms:
100 glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
101 macOS 14, OpenBSD, MSVC 14, Android.
102 @end itemize
104 Portability problems not fixed by Gnulib:
105 @itemize
106 @item
107 The @code{%m} directive is not portable, use @code{%s} mapped to an
108 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
109 instead.
110 @item
111 Formatting noncanonical @samp{long double} numbers produces
112 nonmeaningful results on some platforms:
113 glibc and others, on x86, x86_64, IA-64 CPUs.
114 @item
115 When formatting an integer with grouping flag, this function inserts thousands
116 separators even in the "C" locale on some platforms:
117 NetBSD 5.1.
118 @end itemize