This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/56955] documentation for attribute malloc contradicts itself
- From: "eggert at gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 21 May 2014 04:21:44 +0000
- Subject: [Bug other/56955] documentation for attribute malloc contradicts itself
- Auto-submitted: auto-generated
- References: <bug-56955-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955
--- Comment #14 from Paul Eggert <eggert at gnu dot org> ---
(In reply to Dan Gohman from comment #13)
> *p can't alias a or b without violating the weaker assumption.
Sorry, you've lost me there. Pointers in realloc'ed storage can alias
already-existing pointers, and surely this aliasing can inhibit optimization;
perhaps my example doesn't show this correctly but I expect that other examples
could.
> the weaker assumption would be usable by a much broader set of functions,
> so it may even provide overall stronger alias information in practice.
>From what I've seen so far I tend to agree, but there are contrary opinions,
e.g., Richard Biener's "We cannot use the malloc attribute on realloc, ever."
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=23383#23>. It might be helpful
for Richard to chime in here and explain. Even if GCC does not change the
meaning of __attribute__ ((malloc)), perhaps there should be a new directive
(__attribute__ ((new)), say) with the weaker semantics.
Anyway, the original bug report is about GCC's documentation, and the proposed
patch does fix the documentation bug, so we could start with it.