[PATCH] analyzer: Recognize __builtin_free as a matching deallocator

Siddhesh Poyarekar siddhesh@gotplt.org
Wed Aug 25 15:16:28 GMT 2021

On 8/25/21 5:44 PM, Matthias Klose wrote:
> On 7/28/21 1:44 PM, David Malcolm via Gcc-patches wrote:
>> On Wed, 2021-07-28 at 10:34 +0530, Siddhesh Poyarekar wrote:
>>> Recognize __builtin_free as being equivalent to free when passed into
>>> __attribute__((malloc ())), similar to how it is treated when it is
>>> encountered as a call.  This fixes spurious warnings in glibc where
>>> xmalloc family of allocators as well as reallocarray, memalign,
>>> etc. are declared to have __builtin_free as the free function.
>>>          gcc/analyzer/ChangeLog:
>>>          * sm-malloc.cc
>>>          (malloc_state_machine::get_or_create_deallocator): Recognize
>>>          __builtin_free.
>>>          gcc/testsuite/ChangeLog:
>>>          * gcc.dg/analyzer/attr-malloc-1.c (compatible_alloc,
>>>          compatible_alloc2): New extern allocator declarations.
>>>          (test_9, test_10): New tests.
>> Looks good to me, thanks
>> Dave
> Please could this be backported to all active branches?

Sure, it looks like only gcc11 needs this since malloc attribute 
matching seems recent.  David, I've never done a backport before, may I 
just cherry-pick, push and post a [committed] patch on list or does it 
need to go through review?


More information about the Gcc-patches mailing list