c-std-porting.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* Re: Missing <stdlib.h> include in lib/autoconf/c.m4
       [not found] ` <A7F4BEF8-2E51-4390-A137-4998A19A8EB7@gentoo.org>
@ 2022-11-11  3:18   ` Sam James
  2022-11-11  3:25     ` Zack Weinberg
  0 siblings, 1 reply; 3+ messages in thread
From: Sam James @ 2022-11-11  3:18 UTC (permalink / raw)
  To: Sam James, Zack Weinberg; +Cc: bug-autoconf, c-std-porting

[-- Attachment #1: Type: text/plain, Size: 1471 bytes --]



> On 5 Nov 2022, at 22:37, Sam James <sam@gentoo.org> wrote:
> 
> 
> 
>> On 5 Nov 2022, at 05:07, Sam James <sam@gentoo.org> 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?


[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 358 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Missing <stdlib.h> include in lib/autoconf/c.m4
  2022-11-11  3:18   ` Missing <stdlib.h> include in lib/autoconf/c.m4 Sam James
@ 2022-11-11  3:25     ` Zack Weinberg
  2022-11-11  3:28       ` Sam James
  0 siblings, 1 reply; 3+ messages in thread
From: Zack Weinberg @ 2022-11-11  3:25 UTC (permalink / raw)
  To: Sam James; +Cc: Autoconf Bugs, c-std-porting

On Thu, Nov 10, 2022, at 10:18 PM, Sam James wrote:
>> On 5 Nov 2022, at 22:37, Sam James <sam@gentoo.org> wrote:
>> 
>> 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).

Yeah, we can't include <stdlib.h> here, but it should be OK to add a manual declaration of free (as I did in bf5a75...) -- there was already a manual declaration of malloc, and free doesn't even need size_t.


>> We need another one (<assert.h>) I think for _Static_assert in _AC_C_C11_TEST_GLOBALS too, up until C23?

I think this should be fine as is; in C11, _Static_assert is a keyword / special form, so it's safe to use without <assert.h>.  IIUC the change in C23 is to make static_assert also available without <assert.h>?

zw

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Missing <stdlib.h> include in lib/autoconf/c.m4
  2022-11-11  3:25     ` Zack Weinberg
@ 2022-11-11  3:28       ` Sam James
  0 siblings, 0 replies; 3+ messages in thread
From: Sam James @ 2022-11-11  3:28 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: Autoconf Bugs, c-std-porting

[-- Attachment #1: Type: text/plain, Size: 978 bytes --]



> On 11 Nov 2022, at 03:25, Zack Weinberg <zack@owlfolio.org> wrote:
> 
> On Thu, Nov 10, 2022, at 10:18 PM, Sam James wrote:
>>> On 5 Nov 2022, at 22:37, Sam James <sam@gentoo.org> wrote:
>>> 
>>> 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).
> 
> Yeah, we can't include <stdlib.h> here, but it should be OK to add a manual declaration of free (as I did in bf5a75...) -- there was already a manual declaration of malloc, and free doesn't even need size_t.
> 
> 

Thanks for doing that.

>>> We need another one (<assert.h>) I think for _Static_assert in _AC_C_C11_TEST_GLOBALS too, up until C23?
> 
> I think this should be fine as is; in C11, _Static_assert is a keyword / special form, so it's safe to use without <assert.h>.  IIUC the change in C23 is to make static_assert also available without <assert.h>?
> 

Oh right! We're all good then.

Cheers,
sam

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 358 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-11  3:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <04038EC0-622D-4806-97A3-465124CD25F7@gentoo.org>
     [not found] ` <A7F4BEF8-2E51-4390-A137-4998A19A8EB7@gentoo.org>
2022-11-11  3:18   ` Missing <stdlib.h> include in lib/autoconf/c.m4 Sam James
2022-11-11  3:25     ` Zack Weinberg
2022-11-11  3:28       ` Sam James

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).