* tests/test-bsearch.c: Use another volatile function pointer variable.
* tests/test-memccpy.c: Likewise.
* tests/test-memchr.c: Likewise.
* tests/test-memcmp.c: Likewise.
* tests/test-memcpy.c: Likewise.
* tests/test-memmove.c: Likewise.
* tests/test-memset.c: Likewise.
* tests/test-memset_explicit.c: Likewise.
* tests/test-qsort.c: Likewise.
* tests/test-strncat.c: Likewise.
* tests/test-strncmp.c: Likewise.
* tests/test-strncpy.c: Likewise.
* tests/test-strndup.c: Likewise.
* tests/test-wcsncat.c: Likewise.
* tests/test-wcsncmp.c: Likewise.
* tests/test-wcsncpy.c: Likewise.
* tests/test-wmemchr.c: Likewise.
* tests/test-wmemcmp.c: Likewise.
* tests/test-wmemcpy.c: Likewise.
* tests/test-wmemmove.c: Likewise.
* tests/test-wmemset.c: Likewise.
+2026-08-11 Bruno Haible <bruno@clisp.org>
+
+ tests: Make last patch side-effect free.
+ * tests/test-bsearch.c: Use another volatile function pointer variable.
+ * tests/test-memccpy.c: Likewise.
+ * tests/test-memchr.c: Likewise.
+ * tests/test-memcmp.c: Likewise.
+ * tests/test-memcpy.c: Likewise.
+ * tests/test-memmove.c: Likewise.
+ * tests/test-memset.c: Likewise.
+ * tests/test-memset_explicit.c: Likewise.
+ * tests/test-qsort.c: Likewise.
+ * tests/test-strncat.c: Likewise.
+ * tests/test-strncmp.c: Likewise.
+ * tests/test-strncpy.c: Likewise.
+ * tests/test-strndup.c: Likewise.
+ * tests/test-wcsncat.c: Likewise.
+ * tests/test-wcsncmp.c: Likewise.
+ * tests/test-wcsncpy.c: Likewise.
+ * tests/test-wmemchr.c: Likewise.
+ * tests/test-wmemcmp.c: Likewise.
+ * tests/test-wmemcpy.c: Likewise.
+ * tests/test-wmemmove.c: Likewise.
+ * tests/test-wmemset.c: Likewise.
+
2026-08-11 Lasse Collin <lasse.collin@tukaani.org>
tests: Verify N3322 compatibility of the function prototypes.
#endif
return (void *) p;
}
+static void *(*volatile volatile_null_bsearch) (void const *, void const *,
+ size_t, size_t,
+ int (*) (void const *, void const *))
+ = null_bsearch;
/* Test the library, not the compiler+library. */
static void *
{
return (void *) bsearch (key, base, nel, width, compar);
}
-static void *(*volatile volatile_bsearch) (void const *, void const *, size_t,
- size_t,
- int (*) (void const *, void const *))
+static void *(*volatile volatile_lib_bsearch) (void const *, void const *,
+ size_t, size_t,
+ int (*) (void const *, void const *))
= lib_bsearch;
#undef bsearch
-#define bsearch volatile_bsearch
+#define bsearch volatile_lib_bsearch
static int
cmp (const void *a, const void *b)
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (bsearch ("x", NULL, 0, 1, cmp) == NULL);
- volatile_bsearch = null_bsearch;
- ASSERT (bsearch ("x", NULL, 0, 1, cmp) == NULL);
+ ASSERT (volatile_null_bsearch ("x", NULL, 0, 1, cmp) == NULL);
return test_exit_status;
}
#endif
return p;
}
+static void *(*volatile volatile_null_memccpy) (void *, void const *, int,
+ size_t)
+ = null_memccpy;
/* Test the library, not the compiler+library. */
static void *
{
return memccpy (dest, src, c, n);
}
-static void *(*volatile volatile_memccpy) (void *, void const *, int, size_t)
+static void *(*volatile volatile_lib_memccpy) (void *, void const *, int,
+ size_t)
= lib_memccpy;
#undef memccpy
-#define memccpy volatile_memccpy
+#define memccpy volatile_lib_memccpy
int
main (void)
ASSERT (memccpy (y, NULL, '?', 0) == NULL);
}
- volatile_memccpy = null_memccpy;
- ASSERT (memccpy (NULL, "x", '?', 0) == NULL);
+ ASSERT (volatile_null_memccpy (NULL, "x", '?', 0) == NULL);
return test_exit_status;
}
#endif
return (void *) p;
}
+static void *(*volatile volatile_null_memchr) (void const *, int, size_t)
+ = null_memchr;
/* Test the library, not the compiler+library. */
static void *
{
return (void *) memchr (s, c, n);
}
-static void *(*volatile volatile_memchr) (void const *, int, size_t)
+static void *(*volatile volatile_lib_memchr) (void const *, int, size_t)
= lib_memchr;
#undef memchr
-#define memchr volatile_memchr
+#define memchr volatile_lib_memchr
int
main (void)
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (memchr (NULL, '?', 0) == NULL);
- volatile_memchr = null_memchr;
- ASSERT (memchr (NULL, '?', 0) == NULL);
+ ASSERT (volatile_null_memchr (NULL, '?', 0) == NULL);
return test_exit_status;
}
#endif
return r;
}
+int (*volatile volatile_null_memcmp) (void const *, void const *, size_t)
+ = null_memcmp;
/* Test the library, not the compiler+library. */
static int
{
return memcmp (s1, s2, n);
}
-int (*volatile volatile_memcmp) (void const *, void const *, size_t)
+int (*volatile volatile_lib_memcmp) (void const *, void const *, size_t)
= lib_memcmp;
#undef memcmp
-#define memcmp volatile_memcmp
+#define memcmp volatile_lib_memcmp
int
main (void)
ASSERT (memcmp ("x", NULL, 0) == 0);
ASSERT (memcmp (NULL, NULL, 0) == 0);
- volatile_memcmp = null_memcmp;
- ASSERT (memcmp (NULL, "x", 0) == 0);
+ ASSERT (volatile_null_memcmp (NULL, "x", 0) == 0);
return test_exit_status;
}
#endif
return p;
}
+void *(*volatile volatile_null_memcpy) (void *, void const *, size_t)
+ = null_memcpy;
/* Test the library, not the compiler+library. */
static void *
{
return memcpy (s1, s2, n);
}
-void *(*volatile volatile_memcpy) (void *, void const *, size_t)
+void *(*volatile volatile_lib_memcpy) (void *, void const *, size_t)
= lib_memcpy;
#undef memcpy
-#define memcpy volatile_memcpy
+#define memcpy volatile_lib_memcpy
int
main (void)
/* Redirect via the volatile function pointer to ensure that that the ASSERT
in null_memcpy won't be optimized away by GCC 6.3.0. */
- volatile_memcpy = null_memcpy;
- ASSERT (memcpy (NULL, "x", 0) == NULL);
+ ASSERT (volatile_null_memcpy (NULL, "x", 0) == NULL);
return test_exit_status;
}
#endif
return p;
}
+static void *(*volatile volatile_null_memmove) (void *, void const *, size_t)
+ = null_memmove;
/* Test the library, not the compiler+library. */
static void *
{
return memmove (s1, s2, n);
}
-static void *(*volatile volatile_memmove) (void *, void const *, size_t)
+static void *(*volatile volatile_lib_memmove) (void *, void const *, size_t)
= lib_memmove;
#undef memmove
-#define memmove volatile_memmove
+#define memmove volatile_lib_memmove
int
main (void)
ASSERT (memmove (y, NULL, 0) == y);
}
- volatile_memmove = null_memmove;
- ASSERT (memmove (NULL, "x", 0) == NULL);
+ ASSERT (volatile_null_memmove (NULL, "x", 0) == NULL);
return test_exit_status;
}
#endif
return p;
}
+static void *(*volatile volatile_null_memset) (void *, int, size_t)
+ = null_memset;
/* Test the library, not the compiler+library. */
static void *
{
return memset (s, c, n);
}
-static void *(*volatile volatile_memset) (void *, int, size_t)
+static void *(*volatile volatile_lib_memset) (void *, int, size_t)
= lib_memset;
#undef memset
-#define memset volatile_memset
+#define memset volatile_lib_memset
int
main (void)
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (memset (NULL, '?', 0) == NULL);
- volatile_memset = null_memset;
- ASSERT (memset (NULL, '?', 0) == NULL);
+ ASSERT (volatile_null_memset (NULL, '?', 0) == NULL);
return test_exit_status;
}
#endif
return p;
}
+static void *(*volatile volatile_null_memset_explicit) (void *, int, size_t)
+ = null_memset_explicit;
/* Test the library, not the compiler+library. */
static void *
{
return memset_explicit (s, c, n);
}
-static void *(*volatile volatile_memset_explicit) (void *, int, size_t)
+static void *(*volatile volatile_lib_memset_explicit) (void *, int, size_t)
= lib_memset_explicit;
#undef memset_explicit
-#define memset_explicit volatile_memset_explicit
+#define memset_explicit volatile_lib_memset_explicit
/* Suppress GCC 13.2.1 false alarm, as this test needs a dangling pointer. */
#if _GL_GNUC_PREREQ (12, 0)
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (memset_explicit (NULL, '?', 0) == NULL);
- volatile_memset_explicit = null_memset_explicit;
- ASSERT (memset_explicit (NULL, '?', 0) == NULL);
+ ASSERT (volatile_null_memset_explicit (NULL, '?', 0) == NULL);
return test_exit_status;
}
ASSERT (base == NULL);
#endif
}
+static void (*volatile volatile_null_qsort) (void *, size_t, size_t,
+ int (*) (void const *, void const *))
+ = null_qsort;
/* Test the library, not the compiler+library. */
static void
{
qsort (base, nel, width, compar);
}
-static void (*volatile volatile_qsort) (void *, size_t, size_t,
- int (*) (void const *, void const *))
+static void (*volatile volatile_lib_qsort) (void *, size_t, size_t,
+ int (*) (void const *, void const *))
= lib_qsort;
#undef qsort
-#define qsort volatile_qsort
+#define qsort volatile_lib_qsort
static int
cmp (const void *a, const void *b)
qsort (NULL, 0, 1, cmp);
- volatile_qsort = null_qsort;
- qsort (NULL, 0, 1, cmp);
+ volatile_null_qsort (NULL, 0, 1, cmp);
return 0;
}
#endif
return p;
}
+static char *(*volatile volatile_null_strncat) (char *, char const *, size_t)
+ = null_strncat;
/* Test the library, not the compiler+library. */
static char *
{
return strncat (s1, s2, n);
}
-static char *(*volatile volatile_strncat) (char *, char const *, size_t)
+static char *(*volatile volatile_lib_strncat) (char *, char const *, size_t)
= lib_strncat;
#undef strncat
-#define strncat volatile_strncat
+#define strncat volatile_lib_strncat
#define UNIT char
#define U_STRNCAT strncat
char y[2] = { 'x', '\0' };
ASSERT (strncat (y, NULL, 0) == y);
- volatile_strncat = null_strncat;
- ASSERT (strncat (y, NULL, 0) == y);
+ ASSERT (volatile_null_strncat (y, NULL, 0) == y);
}
return test_exit_status;
#endif
return r;
}
+static int (*volatile volatile_null_strncmp) (char const *, char const *,
+ size_t)
+ = null_strncmp;
/* Test the library, not the compiler+library. */
static int
{
return strncmp (s1, s2, n);
}
-static int (*volatile volatile_strncmp) (char const *, char const *, size_t)
+static int (*volatile volatile_lib_strncmp) (char const *, char const *,
+ size_t)
= lib_strncmp;
#undef strncmp
-#define strncmp volatile_strncmp
+#define strncmp volatile_lib_strncmp
int
main (void)
ASSERT (strncmp ("x", NULL, 0) == 0);
ASSERT (strncmp (NULL, NULL, 0) == 0);
- volatile_strncmp = null_strncmp;
- ASSERT (strncmp (NULL, "x", 0) == 0);
+ ASSERT (volatile_null_strncmp (NULL, "x", 0) == 0);
return test_exit_status;
}
#endif
return p;
}
+static char *(*volatile volatile_null_strncpy) (char *, char const *, size_t)
+ = null_strncpy;
/* Test the library, not the compiler+library. */
static char *
{
return strncpy (s1, s2, n);
}
-static char *(*volatile volatile_strncpy) (char *, char const *, size_t)
+static char *(*volatile volatile_lib_strncpy) (char *, char const *, size_t)
= lib_strncpy;
#undef strncpy
-#define strncpy volatile_strncpy
+#define strncpy volatile_lib_strncpy
#define MAGIC (char)0xBA
char y[1];
ASSERT (strncpy (y, NULL, 0) == y);
- volatile_strncpy = null_strncpy;
- ASSERT (strncpy (y, NULL, 0) == y);
+ ASSERT (volatile_null_strncpy (y, NULL, 0) == y);
}
return test_exit_status;
#endif
return p;
}
+static char *(*volatile volatile_null_strndup) (char const *, size_t)
+ = null_strndup;
/* Test the library, not the compiler+library. */
static char *
{
return strndup (s, size);
}
-static char *(*volatile volatile_strndup) (char const *, size_t)
+static char *(*volatile volatile_lib_strndup) (char const *, size_t)
= lib_strndup;
#undef strndup
-#define strndup volatile_strndup
+#define strndup volatile_lib_strndup
int
main (void)
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (strndup (NULL, 0) != NULL);
- volatile_strndup = null_strndup;
- ASSERT (strndup (NULL, 0) != NULL);
+ ASSERT (volatile_null_strndup (NULL, 0) != NULL);
return test_exit_status;
}
#endif
return p;
}
+static wchar_t *(*volatile volatile_null_wcsncat) (wchar_t *, wchar_t const *,
+ size_t)
+ = null_wcsncat;
/* Test the library, not the compiler+library. */
static wchar_t *
{
return wcsncat (ws1, ws2, n);
}
-static wchar_t *(*volatile volatile_wcsncat) (wchar_t *, wchar_t const *,
- size_t)
+static wchar_t *(*volatile volatile_lib_wcsncat) (wchar_t *, wchar_t const *,
+ size_t)
= lib_wcsncat;
#undef wcsncat
-#define wcsncat volatile_wcsncat
+#define wcsncat volatile_lib_wcsncat
int
main ()
wchar_t y[2] = { L'x', 0 };
ASSERT (wcsncat (y, NULL, 0) == y);
- volatile_wcsncat = null_wcsncat;
- ASSERT (wcsncat (y, NULL, 0) == y);
+ ASSERT (volatile_null_wcsncat (y, NULL, 0) == y);
}
return test_exit_status;
#endif
return r;
}
+static int (*volatile volatile_null_wcsncmp) (wchar_t const *,
+ wchar_t const *, size_t)
+ = null_wcsncmp;
/* Test the library, not the compiler+library. */
static int
{
return wcsncmp (ws1, ws2, n);
}
-static int (*volatile volatile_wcsncmp) (wchar_t const *,
- wchar_t const *, size_t)
+static int (*volatile volatile_lib_wcsncmp) (wchar_t const *,
+ wchar_t const *, size_t)
= lib_wcsncmp;
#undef wcsncmp
-#define wcsncmp volatile_wcsncmp
+#define wcsncmp volatile_lib_wcsncmp
int
main (int argc, char *argv[])
ASSERT (wcsncmp (L"x", NULL, 0) == 0);
ASSERT (wcsncmp (NULL, NULL, 0) == 0);
- volatile_wcsncmp = null_wcsncmp;
- ASSERT (wcsncmp (NULL, L"x", 0) == 0);
+ ASSERT (volatile_null_wcsncmp (NULL, L"x", 0) == 0);
return test_exit_status;
}
#endif
return p;
}
+static wchar_t *(*volatile volatile_null_wcsncpy) (wchar_t *, wchar_t const *,
+ size_t)
+ = null_wcsncpy;
/* Test the library, not the compiler+library. */
static wchar_t *
{
return wcsncpy (ws1, ws2, n);
}
-static wchar_t *(*volatile volatile_wcsncpy) (wchar_t *, wchar_t const *,
- size_t)
+static wchar_t *(*volatile volatile_lib_wcsncpy) (wchar_t *, wchar_t const *,
+ size_t)
= lib_wcsncpy;
#undef wcsncpy
-#define wcsncpy volatile_wcsncpy
+#define wcsncpy volatile_lib_wcsncpy
int
main (void)
wchar_t y[1];
ASSERT (wcsncpy (y, NULL, 0) == y);
- volatile_wcsncpy = null_wcsncpy;
- ASSERT (wcsncpy (y, NULL, 0) == y);
+ ASSERT (volatile_null_wcsncpy (y, NULL, 0) == y);
}
return test_exit_status;
ASSERT (s == NULL);
return (wchar_t *) p;
}
+static wchar_t *(*volatile volatile_null_wmemchr) (wchar_t const *, wchar_t,
+ size_t)
+ = null_wmemchr;
/* Test the library, not the compiler+library. */
static wchar_t *
{
return (wchar_t *) wmemchr (s, wc, n);
}
-static wchar_t *(*volatile volatile_wmemchr) (wchar_t const *, wchar_t, size_t)
+static wchar_t *(*volatile volatile_lib_wmemchr) (wchar_t const *, wchar_t,
+ size_t)
= lib_wmemchr;
#undef wmemchr
-#define wmemchr volatile_wmemchr
+#define wmemchr volatile_lib_wmemchr
int
main (void)
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (wmemchr (NULL, L'?', 0) == NULL);
- volatile_wmemchr = null_wmemchr;
- ASSERT (wmemchr (NULL, L'?', 0) == NULL);
+ ASSERT (volatile_null_wmemchr (NULL, L'?', 0) == NULL);
return test_exit_status;
}
ASSERT (ws1 == NULL);
return r;
}
+int (*volatile volatile_null_wmemcmp) (wchar_t const *, wchar_t const *, size_t)
+ = null_wmemcmp;
/* Test the library, not the compiler+library. */
static int
{
return wmemcmp (ws1, ws2, n);
}
-int (*volatile volatile_wmemcmp) (wchar_t const *, wchar_t const *, size_t)
+int (*volatile volatile_lib_wmemcmp) (wchar_t const *, wchar_t const *, size_t)
= lib_wmemcmp;
#undef wmemcmp
-#define wmemcmp volatile_wmemcmp
+#define wmemcmp volatile_lib_wmemcmp
int
main (int argc, char *argv[])
ASSERT (wmemcmp (L"x", NULL, 0) == 0);
ASSERT (wmemcmp (NULL, NULL, 0) == 0);
- volatile_wmemcmp = null_wmemcmp;
- ASSERT (wmemcmp (NULL, L"x", 0) == 0);
+ ASSERT (volatile_null_wmemcmp (NULL, L"x", 0) == 0);
return test_exit_status;
}
ASSERT (s1 == NULL);
return p;
}
+static wchar_t *(*volatile volatile_null_wmemcpy) (wchar_t *, wchar_t const *,
+ size_t)
+ = null_wmemcpy;
/* Test the library, not the compiler+library. */
static wchar_t *
{
return wmemcpy (s1, s2, n);
}
-static wchar_t *(*volatile volatile_wmemcpy) (wchar_t *, wchar_t const *,
- size_t)
+static wchar_t *(*volatile volatile_lib_wmemcpy) (wchar_t *, wchar_t const *,
+ size_t)
= lib_wmemcpy;
#undef wmemcpy
-#define wmemcpy volatile_wmemcpy
+#define wmemcpy volatile_lib_wmemcpy
int
main (void)
ASSERT (wmemcpy (y, NULL, 0) == y);
}
- volatile_wmemcpy = null_wmemcpy;
- ASSERT (wmemcpy (NULL, L"x", 0) == NULL);
+ ASSERT (volatile_null_wmemcpy (NULL, L"x", 0) == NULL);
return test_exit_status;
}
ASSERT (s1 == NULL);
return p;
}
+static wchar_t *(*volatile volatile_null_wmemmove) (wchar_t *, wchar_t const *,
+ size_t)
+ = null_wmemmove;
/* Test the library, not the compiler+library. */
static wchar_t *
{
return wmemmove (s1, s2, n);
}
-static wchar_t *(*volatile volatile_wmemmove) (wchar_t *, wchar_t const *,
- size_t)
+static wchar_t *(*volatile volatile_lib_wmemmove) (wchar_t *, wchar_t const *,
+ size_t)
= lib_wmemmove;
#undef wmemmove
-#define wmemmove volatile_wmemmove
+#define wmemmove volatile_lib_wmemmove
int
main (void)
ASSERT (wmemmove (y, NULL, 0) == y);
}
- volatile_wmemmove = null_wmemmove;
- ASSERT (wmemmove (NULL, L"x", 0) == NULL);
+ ASSERT (volatile_null_wmemmove (NULL, L"x", 0) == NULL);
return test_exit_status;
}
ASSERT (ws == NULL);
return p;
}
+static wchar_t *(*volatile volatile_null_wmemset) (wchar_t *, wchar_t, size_t)
+ = null_wmemset;
/* Test the library, not the compiler+library. */
static wchar_t *
{
return wmemset (ws, wc, n);
}
-static wchar_t *(*volatile volatile_wmemset) (wchar_t *, wchar_t, size_t)
+static wchar_t *(*volatile volatile_lib_wmemset) (wchar_t *, wchar_t, size_t)
= lib_wmemset;
#undef wmemset
-#define wmemset volatile_wmemset
+#define wmemset volatile_lib_wmemset
int
main (void)
<https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf>. */
ASSERT (wmemset (NULL, L'?', 0) == NULL);
- volatile_wmemset = null_wmemset;
- ASSERT (wmemset (NULL, L'?', 0) == NULL);
+ ASSERT (volatile_null_wmemset (NULL, L'?', 0) == NULL);
return test_exit_status;
}