Hi Collin,

> Since the bug exists from GCC 7.1 ("starts from" on the report) to GCC
> 15, should those two test cases be updated? Maybe an '#if ...' or even
> just a comment so it isn't reported as a new bug in the future.

Your test program shows a failure with -O2 starting with gcc 7.
However, the unit tests (from a testdir of
  sprintf-posix snprintf-posix
) don't fail with any gcc version from 7.5.0 to 13.2.0, with the default CFLAGS.
Nor do they fail with CFLAGS="-O2 -fprintf-return-value" in gcc 13.2.0.
So, it appears that only some other gcc optimization present in gcc 14
(that results in 'my_sprintf' being replaced with 'sprintf') paved the
road to the failure.

Since the bug has been fixed so quickly, I expect that it will be part of
the gcc 14 release series. So, just a comment should be enough.


2024-05-01  Bruno Haible  <br...@clisp.org>

        sprintf-posix, snprintf-posix tests: Add comment.
        Suggested by Collin Funk in
        <https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00546.html>.
        * tests/test-sprintf-posix.h (test_function): Add comment about known
        failures.

diff --git a/tests/test-sprintf-posix.h b/tests/test-sprintf-posix.h
index f09a17fd48..7c545dd345 100644
--- a/tests/test-sprintf-posix.h
+++ b/tests/test-sprintf-posix.h
@@ -3170,6 +3170,9 @@ test_function (int (*my_sprintf) (char *, const char *, 
...))
         as if by a call to the wcrtomb function with a pointer to storage of
         at least MB_CUR_MAX bytes, the wint_t argument converted to wchar_t,
         and an initial shift state."  */
+    /* This test is known to fail
+         - on musl libc,
+         - with gcc 14 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114876>  
*/
     ASSERT (memcmp (result, "a\0z 33\0", 6 + 1) == 0);
     ASSERT (retval == 6);
   }




Reply via email to