diff options
author | Sam James <sam@gentoo.org> | 2024-12-09 23:11:25 +0000 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2024-12-10 01:50:56 +0000 |
commit | a9944a52c967ce76a5894c30d0274b824df43c7a (patch) | |
tree | 5337ce2a52201e1119ada9c0be09b34920e42ee9 /support | |
parent | 28d102d15c6af7f80cb1077e098e020476d26d00 (diff) | |
download | glibc-a9944a52c967ce76a5894c30d0274b824df43c7a.zip glibc-a9944a52c967ce76a5894c30d0274b824df43c7a.tar.gz glibc-a9944a52c967ce76a5894c30d0274b824df43c7a.tar.bz2 |
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 <eggert@cs.ucla.edu>
Diffstat (limited to 'support')
-rw-r--r-- | support/support.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/support/support.h b/support/support.h index ba21ec9..1a77f79 100644 --- a/support/support.h +++ b/support/support.h @@ -113,7 +113,7 @@ void *xposix_memalign (size_t alignment, size_t n) __attribute_malloc__ __attribute_alloc_align__ ((1)) __attribute_alloc_size__ ((2)) __attr_dealloc_free __returns_nonnull; char *xasprintf (const char *format, ...) - __attribute__ ((format (printf, 1, 2), malloc)) __attr_dealloc_free + __attribute__ ((format (printf, 1, 2), __malloc__)) __attr_dealloc_free __returns_nonnull; char *xstrdup (const char *) __attr_dealloc_free __returns_nonnull; char *xstrndup (const char *, size_t) __attr_dealloc_free __returns_nonnull; |