Re: Add malloc attribute to memory allocation functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Tristan Partin" <tristan(at)partin(dot)io>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Add malloc attribute to memory allocation functions
Date: 2026-07-06 04:26:54
Message-ID: 924283.1783312014@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Tristan Partin" <tristan(at)partin(dot)io> writes:
> Given that we now have a tree that compiles fine against
> -Werror=mismatched-dealloc, we need to make sure that we don't regress.
> By adding the malloc attribute[0], we can protect against regressions,
> enable more accurate code coverage with -fanalyzer, and allow the
> compiler to do some optimizations.

I'm skeptical that this is going to lead to anything but grief.
In particular, since gcc has never heard of memory contexts,
I don't see how we are not going to get buried in bogus
-Wanalyzer-malloc-leak warnings. It doesn't really help
to add compiler annotations that only sort-of match our semantics.

(This opinion is based on years of dismissing useless Coverity
warnings of this kind.)

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2026-07-06 04:36:08 Re: postgres_fdw: fix cumulative stats after imported foreign-table stats
Previous Message solai v 2026-07-06 03:54:25 Re: Add malloc attribute to memory allocation functions