> 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 <br...@clisp.org> 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 <float.h> #include <locale.h> #include <stdlib.h> #include <string.h> @@ -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. <https://www.illumos.org/issues/17383> */ { @@ -446,6 +448,7 @@ main (int argc, char *argv[]) char *result = asnprintf (NULL, &length, "%'.500Lg\n", 42351647362715016953416125033982098102569580078125000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.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 <float.h> #include <locale.h> #include <stdlib.h> #include <string.h> @@ -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", 42351647362715016953416125033982098102569580078125000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0L); free (result); } + #endif } return test_exit_status;