Pádraig Brady wrote:
> The attached adds an extra configure time check for this issue,
> and I've verified that fixes the issue for numfmt, printf, seq on Solaris.
Thanks for the investigation and fix.
I'm adding this patch
- to document the issue,
- to add a test case. (We should not need to run the coreutils test suite
in order to detect whether vasnprintf is working right.)
Bruno
From 78a859110fdbd297cedaa8bbba132c60976bfb4c Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Fri, 14 Aug 2026 19:56:38 +0200
Subject: [PATCH] Add unit tests and doc for the %Lf large precision issue on
Solaris.
* tests/test-vasnprintf-posix.c (test_function): Add a testcase for
"%.5119Lf".
* tests/test-vasprintf-posix.c (test_function): Likewise.
* tests/test-snprintf-posix.h (test_function): Likewise.
* tests/test-sprintf-posix.h (test_function): Likewise.
* tests/test-vasnwprintf-posix.c (test_function): Likewise.
* doc/posix-functions/*printf.texi: Document the Solaris 11.4 bug.
---
ChangeLog | 11 +++++++++++
doc/posix-functions/fprintf.texi | 2 +-
doc/posix-functions/printf.texi | 2 +-
doc/posix-functions/snprintf.texi | 2 +-
doc/posix-functions/sprintf.texi | 2 +-
doc/posix-functions/vfprintf.texi | 2 +-
doc/posix-functions/vprintf.texi | 2 +-
doc/posix-functions/vsnprintf.texi | 2 +-
doc/posix-functions/vsprintf.texi | 2 +-
tests/test-snprintf-posix.h | 13 ++++++++++++-
tests/test-sprintf-posix.h | 13 ++++++++++++-
tests/test-vasnprintf-posix.c | 14 ++++++++++++++
tests/test-vasnwprintf-posix.c | 14 ++++++++++++++
tests/test-vasprintf-posix.c | 14 ++++++++++++++
14 files changed, 85 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5ebd27d047..65793e578c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-08-14 Bruno Haible <[email protected]>
+
+ Add unit tests and doc for the %Lf large precision issue on Solaris.
+ * tests/test-vasnprintf-posix.c (test_function): Add a testcase for
+ "%.5119Lf".
+ * tests/test-vasprintf-posix.c (test_function): Likewise.
+ * tests/test-snprintf-posix.h (test_function): Likewise.
+ * tests/test-sprintf-posix.h (test_function): Likewise.
+ * tests/test-vasnwprintf-posix.c (test_function): Likewise.
+ * doc/posix-functions/*printf.texi: Document the Solaris 11.4 bug.
+
2026-08-14 Pádraig Brady <[email protected]>
tests: avoid -Wformat= warning re unsigned mismatch
diff --git a/doc/posix-functions/fprintf.texi b/doc/posix-functions/fprintf.texi
index 2b0f2cb7e2..8e6ef3a3e9 100644
--- a/doc/posix-functions/fprintf.texi
+++ b/doc/posix-functions/fprintf.texi
@@ -103,7 +103,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/doc/posix-functions/printf.texi b/doc/posix-functions/printf.texi
index f57c16ba47..47167fdea2 100644
--- a/doc/posix-functions/printf.texi
+++ b/doc/posix-functions/printf.texi
@@ -103,7 +103,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/doc/posix-functions/snprintf.texi b/doc/posix-functions/snprintf.texi
index 23dd6704fa..ba2578b2ba 100644
--- a/doc/posix-functions/snprintf.texi
+++ b/doc/posix-functions/snprintf.texi
@@ -102,7 +102,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/doc/posix-functions/sprintf.texi b/doc/posix-functions/sprintf.texi
index 8dd59ed611..2948797c6b 100644
--- a/doc/posix-functions/sprintf.texi
+++ b/doc/posix-functions/sprintf.texi
@@ -90,7 +90,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/doc/posix-functions/vfprintf.texi b/doc/posix-functions/vfprintf.texi
index feaa2318c1..52b9491a63 100644
--- a/doc/posix-functions/vfprintf.texi
+++ b/doc/posix-functions/vfprintf.texi
@@ -103,7 +103,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/doc/posix-functions/vprintf.texi b/doc/posix-functions/vprintf.texi
index 1256971aec..97bf877a1a 100644
--- a/doc/posix-functions/vprintf.texi
+++ b/doc/posix-functions/vprintf.texi
@@ -103,7 +103,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/doc/posix-functions/vsnprintf.texi b/doc/posix-functions/vsnprintf.texi
index 8a6ca05706..f23e3967a5 100644
--- a/doc/posix-functions/vsnprintf.texi
+++ b/doc/posix-functions/vsnprintf.texi
@@ -99,7 +99,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/doc/posix-functions/vsprintf.texi b/doc/posix-functions/vsprintf.texi
index b94afc2eca..907bf74443 100644
--- a/doc/posix-functions/vsprintf.texi
+++ b/doc/posix-functions/vsprintf.texi
@@ -90,7 +90,7 @@
This function mishandles large floating point precisions
(for example, formatting 1.0 with @samp{"%.511f"})
on some platforms:
-Solaris 10.
+Solaris 11.4.
@item
This function produces wrong output for the @samp{lc} directive with a NUL
wide character argument on some platforms:
diff --git a/tests/test-snprintf-posix.h b/tests/test-snprintf-posix.h
index d7a3b4eda2..18d285b05b 100644
--- a/tests/test-snprintf-posix.h
+++ b/tests/test-snprintf-posix.h
@@ -79,7 +79,7 @@ static void
test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
{
char buf[8];
- char result[5000];
+ char result[10000];
/* Test return value convention. */
@@ -2955,6 +2955,17 @@ test_function (int (*my_snprintf) (char *, size_t, const char *, ...))
ASSERT (retval == strlen (result));
}
+ {
+ int retval =
+ my_snprintf (result, sizeof (result), "%.5119Lf %d", 1.0L, 99);
+ ASSERT (result[0] == '1');
+ ASSERT (result[1] == '.');
+ for (size_t i = 0; i < 5119; i++)
+ ASSERT (result[2 + i] == '0');
+ ASSERT (streq (result + 2 + 5119, " 99"));
+ ASSERT (retval == strlen (result));
+ }
+
{
char input[5000];
int retval;
diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h
index 40d4be65c6..007b8ba56d 100644
--- a/tests/test-sprintf-posix.h
+++ b/tests/test-sprintf-posix.h
@@ -78,7 +78,7 @@ strisnan (const char *string, size_t start_index, size_t end_index, int uppercas
static void
test_function (int (*my_sprintf) (char *, const char *, ...))
{
- char result[5000];
+ char result[10000];
char buf[8];
/* Test return value convention. */
@@ -2942,6 +2942,17 @@ test_function (int (*my_sprintf) (char *, const char *, ...))
ASSERT (retval == strlen (result));
}
+ {
+ int retval =
+ my_sprintf (result, "%.5119Lf %d", 1.0L, 99);
+ ASSERT (result[0] == '1');
+ ASSERT (result[1] == '.');
+ for (size_t i = 0; i < 5119; i++)
+ ASSERT (result[2 + i] == '0');
+ ASSERT (streq (result + 2 + 5119, " 99"));
+ ASSERT (retval == strlen (result));
+ }
+
{
char input[5000];
int retval;
diff --git a/tests/test-vasnprintf-posix.c b/tests/test-vasnprintf-posix.c
index fe0a59d647..9019f8d460 100644
--- a/tests/test-vasnprintf-posix.c
+++ b/tests/test-vasnprintf-posix.c
@@ -3809,6 +3809,20 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
free (result);
}
+ {
+ size_t length;
+ char *result =
+ my_asnprintf (NULL, &length, "%.5119Lf %d", 1.0L, 99);
+ ASSERT (result != NULL);
+ ASSERT (result[0] == '1');
+ ASSERT (result[1] == '.');
+ for (size_t i = 0; i < 5119; i++)
+ ASSERT (result[2 + i] == '0');
+ ASSERT (streq (result + 2 + 5119, " 99"));
+ ASSERT (length == strlen (result));
+ free (result);
+ }
+
{
char input[5000];
size_t length;
diff --git a/tests/test-vasnwprintf-posix.c b/tests/test-vasnwprintf-posix.c
index d1b3d6e0bb..765b21b57a 100644
--- a/tests/test-vasnwprintf-posix.c
+++ b/tests/test-vasnwprintf-posix.c
@@ -3813,6 +3813,20 @@ test_function (wchar_t * (*my_asnwprintf) (wchar_t *, size_t *, const wchar_t *,
free (result);
}
+ {
+ size_t length;
+ wchar_t *result =
+ my_asnwprintf (NULL, &length, L"%.5119Lf %d", 1.0L, 99);
+ ASSERT (result != NULL);
+ ASSERT (result[0] == '1');
+ ASSERT (result[1] == '.');
+ for (size_t i = 0; i < 5119; i++)
+ ASSERT (result[2 + i] == '0');
+ ASSERT (wcscmp (result + 2 + 5119, L" 99") == 0);
+ ASSERT (length == wcslen (result));
+ free (result);
+ }
+
{
char input[5000];
size_t length;
diff --git a/tests/test-vasprintf-posix.c b/tests/test-vasprintf-posix.c
index 6d62468cce..d38541ffb4 100644
--- a/tests/test-vasprintf-posix.c
+++ b/tests/test-vasprintf-posix.c
@@ -3793,6 +3793,20 @@ test_function (int (*my_asprintf) (char **, const char *, ...))
free (result);
}
+ {
+ char *result;
+ int retval =
+ my_asprintf (&result, "%.5119Lf %d", 1.0L, 99);
+ ASSERT (result != NULL);
+ ASSERT (result[0] == '1');
+ ASSERT (result[1] == '.');
+ for (size_t i = 0; i < 5119; i++)
+ ASSERT (result[2 + i] == '0');
+ ASSERT (streq (result + 2 + 5119, " 99"));
+ ASSERT (retval == strlen (result));
+ free (result);
+ }
+
{
char input[5000];
char *result;
--
2.53.0