On 13/08/2026 00:46, Pádraig Brady wrote:
Bruno Haible wrote:> Today I see two tests fail on Solaris 11.4:

FAIL: tests/seq/seq-precision
FAIL: tests/printf/printf

Probably caused by commit 47f57665d5041b63f6e84746f9371eb6fac1a13a.

Find attached the log file.

Interesting. On Solaris we put a trailing e+00
once the precision goes above 5119?

    $ src/seq -f %.5118f 1 | src/tail -c5
    0000

    $ src/seq -f %.5119f 1 | src/tail -c5
    e+00

It seems to be our vasnprintf replacement that's triggering it
as the system printf doesn't show this:

    $ /bin/printf %.70000f 1 | src/wc -c
    70002
    $ src/printf %.70000f 1 | src/wc -c
    70006

I can work around it in the test, but this seems like a real bug,
as %f should never emit exponential notation right?

I'll have a look tomorrow if no-one gets to it first.
Actually the system /bin/printf doesn't show it as it uses double.
The problem only shows up in Solaris' libc with long double
(which GNU printf uses internally).

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.

Note seq and numfmt required additional tweaks in coreutils
to depend on printf-posix and snprint-posix, so that those are replaced.
We'd previously avoided that¹, but on current glibc these are not replaced
so these are acceptable dependencies now I think.

cheers,
Padraig

¹
https://lists.gnu.org/archive/html/coreutils/2014-11/msg00046.html
https://github.com/coreutils/coreutils/commit/b817f6276
From 90edf8eb5dd3cbf0c5d9b4cd13eb2028694541cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Fri, 14 Aug 2026 13:13:34 +0100
Subject: [PATCH] *printf: Detect %Lf large precision issue on Solaris

* m4/printf.m4 (gl_PRINTF_LONG_DOUBLE): Detect extraneous e+00
output when the output exceeds 5120 bytes, seen on Solaris 11.4.
---
 ChangeLog    |  6 ++++++
 m4/printf.m4 | 17 ++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 63cf49d0e5..f67fc67405 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-08-14  Pádraig Brady  <[email protected]>
+
+	*printf: Detect %Lf large precision issue on Solaris
+	* m4/printf.m4 (gl_PRINTF_LONG_DOUBLE): Detect extraneous e+00
+	output when the output exceeds 5120 bytes, seen on Solaris 11.4.
+
 2026-08-13  Lasse Collin  <[email protected]>
 
 	tests: Fix test-wmemcpy and test-wmemmove on mingw-w64 + GCC < 15.
diff --git a/m4/printf.m4 b/m4/printf.m4
index 0de493b690..f0bfea1f3a 100644
--- a/m4/printf.m4
+++ b/m4/printf.m4
@@ -1,5 +1,5 @@
 # printf.m4
-# serial 98
+# serial 99
 dnl Copyright (C) 2003, 2007-2026 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -1437,6 +1437,8 @@ dnl than 510 in floating-point output crash the program. On Solaris 10/SPARC,
 dnl precisions larger than 510 in floating-point output yield wrong results.
 dnl On AIX 7.1, precisions larger than 998 in floating-point output yield
 dnl wrong results. On BeOS, precisions larger than 1044 crash the program.
+dnl On Solaris 11, large precisions with a 'long double' argument and the
+dnl 'f' directive can mistakenly produce exponential notation.
 dnl Result is gl_cv_func_printf_precision.
 
 AC_DEFUN([gl_PRINTF_PRECISION],
@@ -1450,7 +1452,7 @@ AC_DEFUN([gl_PRINTF_PRECISION],
         [AC_LANG_SOURCE([[
 #include <stdio.h>
 #include <string.h>
-static char buf[5000];
+static char buf[10000];
 int main ()
 {
   int result = 0;
@@ -1468,6 +1470,11 @@ int main ()
   if (sprintf (buf, "%.999f %d", 1.0, 33, 44) < 999 + 5
       || buf[0] != '1')
     result |= 4;
+  if (sprintf (buf, "%.5119Lf", 1.0L) != 5121
+      || buf[0] != '1'
+      || buf[1] != '.'
+      || strcmp (buf + 5117, "0000") != 0)
+    result |= 8;
   return result;
 }]])],
         [gl_cv_func_printf_precision=yes],
@@ -2316,9 +2323,9 @@ dnl   OpenBSD 3.9, 4.0               .  #  .  #  #  #  #  #  #  .  #  .  .  #  ?
 dnl   Cygwin 1.7.0 (2009)            .  #  .  .  #  .  #  #  .  .  ?  ?  .  .  ?  ?  .  .  ?  .  ?  .  .  .  .  .  .  ?  ?  ?
 dnl   Cygwin 1.5.25 (2008)           .  #  .  .  #  #  #  #  .  .  #  ?  .  .  ?  ?  .  .  ?  .  #  .  .  .  .  .  .  ?  ?  ?
 dnl   Cygwin 1.5.19 (2006)           #  #  .  .  #  #  #  #  #  .  #  ?  .  #  ?  ?  .  #  ?  #  #  .  .  .  .  .  .  ?  ?  ?
-dnl   Solaris 11.4                   .  #  .  #  #  #  #  #  .  .  #  .  .  .  #  #  .  #  .  .  .  .  .  .  .  .  .  .  #  .
-dnl   Solaris 11.3                   .  #  .  .  .  #  #  #  .  .  #  .  .  .  ?  ?  .  .  .  .  .  .  .  .  .  .  .  .  #  .
-dnl   Solaris 11.0                   .  #  .  #  #  #  #  #  .  .  #  .  .  .  ?  ?  .  #  .  .  .  .  .  .  .  .  .  ?  ?  ?
+dnl   Solaris 11.4                   .  #  .  #  #  #  #  #  .  .  #  .  .  .  #  #  .  #  .  #  .  .  .  .  .  .  .  .  #  .
+dnl   Solaris 11.3                   .  #  .  .  .  #  #  #  .  .  #  .  .  .  ?  ?  .  .  .  ?  .  .  .  .  .  .  .  .  #  .
+dnl   Solaris 11.0                   .  #  .  #  #  #  #  #  .  .  #  .  .  .  ?  ?  .  #  .  ?  .  .  .  .  .  .  .  ?  ?  ?
 dnl   Solaris 10                     .  #  .  #  #  #  #  #  .  .  #  .  .  .  #  #  .  #  .  #  .  .  .  .  .  .  .  .  #  .
 dnl   Solaris 2.6 ... 9              #  #  .  #  #  #  #  #  #  .  #  .  .  .  ?  ?  .  #  ?  #  .  .  .  #  .  .  .  ?  ?  ?
 dnl   Solaris 2.5.1                  #  #  .  #  #  #  #  #  #  .  #  .  .  .  ?  ?  .  #  ?  .  .  #  #  #  #  #  #  ?  ?  ?
-- 
2.55.0

Reply via email to