diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-08-01 22:27:49 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-08-01 22:28:48 -0700 |
commit | 9b69ffb766a2f6c0a06ad4b71040209534fde094 (patch) | |
tree | 91595e961514d1f2710c769516b1d1d9c1d08e9f /m4/gnulib-common.m4 | |
parent | 49782e402f5cd7b3fa83eae9c425715c94fc459d (diff) | |
download | gnulib-9b69ffb766a2f6c0a06ad4b71040209534fde094.tar.gz |
xalloc: no attribute (malloc (free)) on inline
The GCC manual says you can’t use __attribute__ ((__malloc__
(free, 1))) on inline functions. Problem discovered when
compiling diffutils 3.8 on RHEL 8.4 using a GCC 11.2.0 that I
built myself. Perhaps the problem was not discovered earlier
because the attribute works with ‘free’ (which is what I was
seeing before on Fedora 34) but not with ‘rpl_free’ (seen on RHEL
8.4). Anyway, the GCC manual says it shouldn’t work at all, so
don’t use it.
* lib/xalloc.h (xnmalloc, xcharalloc): No longer inline.
* lib/xmalloc.c (xcharalloc, xnmalloc): Move function bodies here.
* m4/gnulib-common.m4 (_GL_ATTRIBUTE_DEALLOC)
(_GL_ATTRIBUTE_DEALLOC_FREE): Document that these cannot be
used on inline functions, as per the GCC 11.2.1 manual.
Diffstat (limited to 'm4/gnulib-common.m4')
-rw-r--r-- | m4/gnulib-common.m4 | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 2872ecdf77..ddbc7b7736 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -152,7 +152,8 @@ AC_DEFUN([gl_COMMON_BODY], [ that can be freed by passing them as the Ith argument to the function F. _GL_ATTRIBUTE_DEALLOC_FREE is for functions that return pointers that can be freed via 'free'; it can be used - only after including stdlib.h. */ + only after including stdlib.h. These macros cannot be used on + inline functions. */ #if _GL_GNUC_PREREQ (11, 0) # define _GL_ATTRIBUTE_DEALLOC(f, i) __attribute__ ((__malloc__ (f, i))) #else |