Last week, I did: > 2024-10-31 Bruno Haible <br...@clisp.org> > > calloc-posix: Add tests. > * tests/test-calloc-posix.c: New file. > * modules/calloc-posix-tests: New file. > > 2024-10-31 Bruno Haible <br...@clisp.org> > > malloc-posix: Add tests. > * tests/test-malloc-posix.c: New file. > * modules/malloc-posix-tests: New file.
These tests fail, even on glibc systems, when clang is used as compiler. It's a clang bug: <https://github.com/llvm/llvm-project/issues/114772> This patch adds workarounds. 2024-11-04 Bruno Haible <br...@clisp.org> malloc, calloc, realloc tests: Work around clang optimization bug. * tests/test-malloc-posix.c (my_malloc): New variable. * tests/test-calloc-posix.c (my_calloc): New variable. * tests/test-realloc-posix.c (my_realloc): New variable. diff --git a/tests/test-calloc-posix.c b/tests/test-calloc-posix.c index d75a255cf5..5fb5c3baa2 100644 --- a/tests/test-calloc-posix.c +++ b/tests/test-calloc-posix.c @@ -25,6 +25,11 @@ #include "macros.h" +/* Work around clang bug + <https://github.com/llvm/llvm-project/issues/114772>. */ +void *(* volatile my_calloc) (size_t, size_t) = calloc; +#define calloc my_calloc + int main () { diff --git a/tests/test-malloc-posix.c b/tests/test-malloc-posix.c index 7a89b0ab79..191b9d1048 100644 --- a/tests/test-malloc-posix.c +++ b/tests/test-malloc-posix.c @@ -25,6 +25,11 @@ #include "macros.h" +/* Work around clang bug + <https://github.com/llvm/llvm-project/issues/114772>. */ +void *(* volatile my_malloc) (size_t) = malloc; +#define malloc my_malloc + int main () { diff --git a/tests/test-realloc-posix.c b/tests/test-realloc-posix.c index 804d8f24e5..c6d62e1d30 100644 --- a/tests/test-realloc-posix.c +++ b/tests/test-realloc-posix.c @@ -24,6 +24,11 @@ #include "macros.h" +/* Work around clang bug + <https://github.com/llvm/llvm-project/issues/114772>. */ +void *(* volatile my_realloc) (void *, size_t) = realloc; +#define realloc my_realloc + int main (int argc, _GL_UNUSED char **argv) {