From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id D880739484AC for ; Mon, 25 Jan 2021 11:31:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D880739484AC Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-408-uIEN1n9gOLKdpGQUpNcmmQ-1; Mon, 25 Jan 2021 06:31:25 -0500 X-MC-Unique: uIEN1n9gOLKdpGQUpNcmmQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3ED11005E40; Mon, 25 Jan 2021 11:31:23 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-35.ams2.redhat.com [10.36.113.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEF1010016F6; Mon, 25 Jan 2021 11:31:22 +0000 (UTC) From: Florian Weimer To: Martin Sebor via Libc-alpha Cc: Martin Sebor , Joseph Myers Subject: Re: [PATCH] add support for -Wmismatched-dealloc References: <74efece7-9a4b-83ee-7fdd-475c0d514378@gmail.com> <758e723b-67cf-a211-7bc2-2ccd3fc744e5@gmail.com> <2555516b-4583-21fc-e844-fd44619488cd@gmail.com> <655918b2-16c6-74b1-6a49-505a7607007f@gmail.com> <87mtxok7ob.fsf@oldenburg2.str.redhat.com> <0aae9006-6001-8fc8-ad6d-c8e3ee60f82c@gmail.com> <87turwiqqw.fsf@oldenburg2.str.redhat.com> <87czybsuoe.fsf@oldenburg2.str.redhat.com> Date: Mon, 25 Jan 2021 12:31:20 +0100 In-Reply-To: (Martin Sebor via Libc-alpha's message of "Mon, 11 Jan 2021 17:01:42 -0700") Message-ID: <87a6sxjlrr.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Jan 2021 11:31:30 -0000 * 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)); > =20 > +/* 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; > =20 > -/* 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 =E2=80=98void* reallocarra= y(void*, size_t, size_t)=E2=80=99 has a different exception specifier 568 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __si= ze) | ^~~~~~~~~~~~ ../stdlib/stdlib.h:562:14: note: from previous declaration =E2=80=98void* r= eallocarray(void*, size_t, size_t) noexcept=E2=80=99 562 | extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __si= ze) | ^~~~~~~~~~~~ Thanks, Florian --=20 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'N= eill