From a9944a52c967ce76a5894c30d0274b824df43c7a Mon Sep 17 00:00:00 2001 From: Sam James Date: Mon, 9 Dec 2024 23:11:25 +0000 Subject: malloc: add indirection for malloc(-like) functions in tests [BZ #32366] GCC 15 introduces allocation dead code removal (DCE) for PR117370 in r15-5255-g7828dc070510f8. This breaks various glibc tests which want to assert various properties of the allocator without doing anything obviously useful with the allocated memory. Alexander Monakov rightly pointed out that we can and should do better than passing -fno-malloc-dce to paper over the problem. Not least because GCC 14 already does such DCE where there's no testing of malloc's return value against NULL, and LLVM has such optimisations too. Handle this by providing malloc (and friends) wrappers with a volatile function pointer to obscure that we're calling malloc (et. al) from the compiler. Reviewed-by: Paul Eggert --- malloc/tst-realloc.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'malloc/tst-realloc.c') diff --git a/malloc/tst-realloc.c b/malloc/tst-realloc.c index f50499e..74a28fb 100644 --- a/malloc/tst-realloc.c +++ b/malloc/tst-realloc.c @@ -23,6 +23,8 @@ #include #include +#include "tst-malloc-aux.h" + static int do_test (void) { -- cgit v1.1