Re: Missing <stdlib.h> include in lib/autoconf/c.m4

Sam James <[email protected]> Fri, 11 Nov 2022 03:18:05 +0000
Newsgroups dev.linux.lists.c-std-porting
Message-ID <[email protected]>

> On 5 Nov 2022, at 22:37, Sam James <[email protected]> wrote:
> 
> 
> 
>> On 5 Nov 2022, at 05:07, Sam James <[email protected]> wrote:
>> 
>> Hello,
>> 
>> When working on Clang 16 (and presumably GCC 14) porting [0], I noticed the following
>> when building GNU grep 3.8:
>> ```
>> configure:6215: checking for clang-16 option to enable C11 features
>> configure:6230: clang-16  -c -g -O2  conftest.c >&5
>> conftest.c:26:14: warning: a function definition without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
>> static char *e (p, i)
>>            ^
>> conftest.c:246:3: error: call to undeclared library function 'free' with type 'void (void *)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
>> free (ia);
>> ^
>> conftest.c:246:3: note: include the header <stdlib.h> or explicitly provide a declaration for 'free'
>> 1 warning and 1 error generated.
>> [...]
>> ```
> 
> I would send a patch for the original issue but I'm wondering how to handle freestanding (see big comment above _AC_C_C89_TEST_GLOBALS).
> 
> We need another one (<assert.h>) I think for _Static_assert in _AC_C_C11_TEST_GLOBALS too, up until C23?
> 

It looks like the original issue is fixed (https://git.savannah.gnu.org/cgit/autoconf.git/commit/?id=bf5a75953b6d504f0405b1ca33b039b8dd39eef4)
but I think we still need treatment for _Static_assert?
signature.asc (application/pgp-signature, 358 B)
-----BEGIN PGP SIGNATURE-----

iNUEARYKAH0WIQQlpruI3Zt2TGtVQcJzhAn1IN+RkAUCY22+7l8UgAAAAAAuAChp
c3N1ZXItZnByQG5vdGF0aW9ucy5vcGVucGdwLmZpZnRoaG9yc2VtYW4ubmV0MjVB
NkJCODhERDlCNzY0QzZCNTU0MUMyNzM4NDA5RjUyMERGOTE5MAAKCRBzhAn1IN+R
kBG4AP9NgZeNOEOTioSONYqao3oDbYHXOWheua6sBs/8RH+CNwEAktOoE8DxIqae
ZSNpZsxjeeitE/uKl136QsPEwQBwpwQ=
=Tfi3
-----END PGP SIGNATURE-----