Re: vasnprintf tests: Add a test case that showcases a Solaris bug

2025-04-13 Thread Bruno Haible via Gnulib discussion list
>   vasnprintf tests: Add a test case that showcases a Solaris bug.
>   * tests/test-vasnprintf-posix2.c (main): Add one more %'g test.

Oops, MSVC gives a compilation error "error C2177: constant too big".

This patch fixes it.


2025-04-13  Bruno Haible  

vasnprintf tests: Fix compilation error on MSVC (regression yesterday).
* tests/test-vasnprintf-posix2.c (main): Disable the new test on
platforms where the 'long double' value range is insufficient.
* tests/test-vasnwprintf-posix2.c (main): Likewise.

diff --git a/tests/test-vasnprintf-posix2.c b/tests/test-vasnprintf-posix2.c
index 55e26d666f..55af1f7484 100644
--- a/tests/test-vasnprintf-posix2.c
+++ b/tests/test-vasnprintf-posix2.c
@@ -20,6 +20,7 @@
 
 #include "vasnprintf.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -439,6 +440,7 @@ main (int argc, char *argv[])
 }
   free (result);
 }
+#if LDBL_MAX_10_EXP > 500
 /* This test used to crash in the Solaris libc, for all Solaris versions.
  */
 {
@@ -446,6 +448,7 @@ main (int argc, char *argv[])
   char *result = asnprintf (NULL, &length, "%'.500Lg\n", 
4235164736271501695341612503398209810256958007812500.0L);
   free (result);
 }
+#endif
   }
 
   return test_exit_status;
diff --git a/tests/test-vasnwprintf-posix2.c b/tests/test-vasnwprintf-posix2.c
index 394e872e26..719c932a41 100644
--- a/tests/test-vasnwprintf-posix2.c
+++ b/tests/test-vasnwprintf-posix2.c
@@ -20,6 +20,7 @@
 
 #include "vasnwprintf.h"
 
+#include 
 #include 
 #include 
 #include 
@@ -345,11 +346,13 @@ main (int argc, char *argv[])
   && wcscmp (result + 7, L"000") == 0);
   free (result);
 }
+#if LDBL_MAX_10_EXP > 500
 {
   size_t length;
   wchar_t *result = asnwprintf (NULL, &length, L"%'.500Lg\n", 
4235164736271501695341612503398209810256958007812500.0L);
   free (result);
 }
+#endif
   }
 
   return test_exit_status;






Re: vasnprintf tests: Add a test case that showcases a Solaris bug

2025-04-12 Thread Collin Funk
Bruno Haible via Gnulib discussion list  writes:

> In printf implementations, it is easy to miss the fact that for %.50g
> the implementation needs to allocate room for the thousands-separators.
> I checked various systems, and Solaris printf() was found to crash in
> such circumstances.

Good catch!

Collin