[clang] [Clang] Allow malloc for functions returning structs (PR #165433)
Aleksandr Nogikh via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 6 06:17:30 PST 2025
a-nogikh wrote:
Thank you for the feedback!
* I've sent an email to gcc at gcc.gnu.org: https://gcc.gnu.org/pipermail/gcc/2025-November/246931.html
* Dropped the `alloc_size`-related changes from the PR: after some more consideration, they didn't seem really necessary and only complicated the changeset.
* Added a bullet to ReleaseNotes and extended the documentation for the attribute.
***
> Is there a reason why a new attribute name can't be used instead? Like say `malloc_span` and `alloc_size_span`. This should make easier to keep things working when trying with say `__has_attribute` and older clang/gcc and you don't need to hard code the exact version of clang/gcc where the support was added. I know GCC's malloc attribute added an extra argument which is hard to test for except via a feature test via an autoconf like but I feel like that was a mistake [one which we need to live with now] (I didn't think of the issue back when GCC added that support nor I responded to the review back then either).
If adding a new `malloc_span` attribute will simplify the usage / prevent incompatibilities with GCC, that sounds totally reasonable to me, thanks for the suggestion. I can prepare an alternative PR that will do this instead.
https://github.com/llvm/llvm-project/pull/165433
More information about the cfe-commits
mailing list