On 2026-08-12 Bruno Haible wrote: > The multiplatform CI shows two test failures on mingw (that I can > reproduce locally): [...] > They are probably due to the definition of wmemcpy and wmemmove as > inline functions (that redirect to memcpy and memmove, respectively) > in mingw's <wchar.h>. > > How should we handle this? Just skip the tests #if defined > __MINGW32__ ? Or do you see something better?
I didn't run the tests now, but I cross-compiled and looked at the assembly. The code looks good with GCC 16.1 + mingw-w64 14.0.0. If you tested with GCC < 15, then the attached patch should fix it. -- Lasse Collin
>From da247b4e520b652a7c6184277211d7222b588b47 Mon Sep 17 00:00:00 2001 From: Lasse Collin <[email protected]> Date: Wed, 12 Aug 2026 22:59:13 +0300 Subject: [PATCH] tests: Fix test-wmemcpy and test-wmemmove on mingw-w64 + GCC < 15 * tests/test-wmemcpy.c: Exclude the N3322 test null_wmemcpy on mingw-w64 && GCC < 15. * tests/test-wmemmove.c: Likewise for null_wmemmove. --- ChangeLog | 7 +++++++ tests/test-wmemcpy.c | 7 ++++++- tests/test-wmemmove.c | 7 ++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe2bd22dd8..2f078b7cc7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2026-08-12 Lasse Collin <[email protected]> + + tests: Fix test-wmemcpy and test-wmemmove on mingw-w64 + GCC < 15. + * tests/test-wmemcpy.c: Exclude the N3322 test null_wmemcpy on + mingw-w64 && GCC < 15. + * tests/test-wmemmove.c: Likewise for null_wmemmove. + 2026-08-12 Bruno Haible <[email protected]> omap-c++: Avoid clang UBSAN runtime errors. diff --git a/tests/test-wmemcpy.c b/tests/test-wmemcpy.c index 9f4da1e424..b66a0140ff 100644 --- a/tests/test-wmemcpy.c +++ b/tests/test-wmemcpy.c @@ -23,12 +23,17 @@ #include "macros.h" -/* Test the prototype in <wchar.h> + compiler. */ +/* Test the prototype in <wchar.h> + compiler. + In mingw-w64 14.0.0, wmemcpy is an inline function that calls memcpy. + In GCC < 15, memcpy is a builtin that has the nonnull attribute. */ static wchar_t * null_wmemcpy (wchar_t *s1, wchar_t const *s2, size_t n) { wchar_t *p = wmemcpy (s1, s2, n); +#if ! defined __MINGW32__ \ + || ! defined __GNUC__ || __GNUC__ >= 15 || defined __clang__ ASSERT (s1 == NULL); +#endif return p; } static wchar_t *(*volatile volatile_null_wmemcpy) (wchar_t *, wchar_t const *, diff --git a/tests/test-wmemmove.c b/tests/test-wmemmove.c index f02be6b092..758dc8b3d2 100644 --- a/tests/test-wmemmove.c +++ b/tests/test-wmemmove.c @@ -23,12 +23,17 @@ #include "macros.h" -/* Test the prototype in <wchar.h> + compiler. */ +/* Test the prototype in <wchar.h> + compiler. + In mingw-w64 14.0.0, wmemmove is an inline function that calls memmove. + In GCC < 15, memmove is a builtin that has the nonnull attribute. */ static wchar_t * null_wmemmove (wchar_t *s1, wchar_t const *s2, size_t n) { wchar_t *p = wmemmove (s1, s2, n); +#if ! defined __MINGW32__ \ + || ! defined __GNUC__ || __GNUC__ >= 15 || defined __clang__ ASSERT (s1 == NULL); +#endif return p; } static wchar_t *(*volatile volatile_null_wmemmove) (wchar_t *, wchar_t const *, -- 2.55.0
