From: Florian Weimer <fweimer@redhat.com>
To: Martin Sebor via Libc-alpha <libc-alpha@sourceware.org>
Cc: Martin Sebor <msebor@gmail.com>, Joseph Myers <joseph@codesourcery.com>
Subject: Re: [PATCH] add support for -Wmismatched-dealloc
Date: Mon, 25 Jan 2021 12:31:20 +0100 [thread overview]
Message-ID: <87a6sxjlrr.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <e78b5e6d-391b-5312-cfde-5944bc51f7d3@gmail.com> (Martin Sebor via Libc-alpha's message of "Mon, 11 Jan 2021 17:01:42 -0700")
* Martin Sebor via Libc-alpha:
> diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
> index 6360845d98..a555fb9c0f 100644
> --- a/stdlib/stdlib.h
> +++ b/stdlib/stdlib.h
> @@ -550,6 +550,9 @@ extern void *calloc (size_t __nmemb, size_t __size)
> extern void *realloc (void *__ptr, size_t __size)
> __THROW __attribute_warn_unused_result__ __attribute_alloc_size__ ((2));
>
> +/* Free a block allocated by `malloc', `realloc' or `calloc'. */
> +extern void free (void *__ptr) __THROW;
> +
> #ifdef __USE_MISC
> /* Re-allocate the previously allocated block in PTR, making the new
> block large enough for NMEMB elements of SIZE bytes each. */
> @@ -558,11 +561,13 @@ extern void *realloc (void *__ptr, size_t __size)
> between objects pointed by the old and new pointers. */
> extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
> __THROW __attribute_warn_unused_result__
> - __attribute_alloc_size__ ((2, 3));
> -#endif
> + __attribute_alloc_size__ ((2, 3))
> + __attr_dealloc_free;
>
> -/* Free a block allocated by `malloc', `realloc' or `calloc'. */
> -extern void free (void *__ptr) __THROW;
> +/* Add reallocarray as its own deallocator. */
> +extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
> + __attr_dealloc (reallocarray, 1);
> +#endif
This causes:
In file included from ../include/stdlib.h:15,
from ../test-skeleton.c:36,
from test-math-iszero.cc:164:
../stdlib/stdlib.h:568:14: error: declaration of ‘void* reallocarray(void*, size_t, size_t)’ has a different exception specifier
568 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~~~~~~~
../stdlib/stdlib.h:562:14: note: from previous declaration ‘void* reallocarray(void*, size_t, size_t) noexcept’
562 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
| ^~~~~~~~~~~~
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
next prev parent reply other threads:[~2021-01-25 11:31 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-08 22:52 Martin Sebor
2020-12-09 0:07 ` Joseph Myers
2020-12-12 2:25 ` Martin Sebor
2020-12-14 21:39 ` Martin Sebor
2020-12-14 22:16 ` Florian Weimer
2020-12-15 1:01 ` Joseph Myers
2020-12-15 16:52 ` Martin Sebor
2020-12-27 23:13 ` Martin Sebor
2021-01-04 15:56 ` Ping: " Martin Sebor
2021-01-04 16:07 ` Florian Weimer
2021-01-04 16:18 ` Martin Sebor
2021-01-04 16:57 ` Florian Weimer
2021-01-04 23:18 ` Martin Sebor
2021-01-10 20:42 ` Ping: " Martin Sebor
2021-01-11 9:13 ` Florian Weimer
2021-01-12 0:00 ` Martin Sebor
2021-01-12 0:01 ` Martin Sebor
2021-01-12 8:59 ` Florian Weimer
2021-01-19 1:08 ` Martin Sebor
2021-01-19 16:54 ` David Malcolm
2021-01-22 21:26 ` DJ Delorie
2021-01-25 10:56 ` Florian Weimer
2021-01-25 11:31 ` Florian Weimer [this message]
2021-04-23 0:00 ` Martin Sebor
2021-05-06 23:54 ` Martin Sebor
2021-05-13 21:49 ` Martin Sebor
2021-05-16 21:25 ` Martin Sebor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a6sxjlrr.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=joseph@codesourcery.com \
--cc=libc-alpha@sourceware.org \
--cc=msebor@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).