[PATCH] add alloc_size attribute

Richard Guenther richard.guenther@gmail.com
Wed May 9 14:40:00 GMT 2007


On 5/9/07, Jakub Jelinek <jakub@redhat.com> wrote:
> On Wed, May 09, 2007 at 03:15:47PM +0200, Dirk Mueller wrote:
> > On Wednesday, 25. April 2007, Richard Guenther wrote:
> >
> > > Otherwise this looks ok.  Please make the suggested changes and
> > > re-post the patch.
> >
> > bootstrapped/regtested on x86_64-suse-linux
> >
> > 2007-04-25  Dirk Mueller  <dmueller@suse.de>
> >         Marcus Meissner <meissner@suse.de>
> >
> >         * doc/extend.texi (alloc_size): New attribute.
> >         * c-common.c (handle_alloc_size_attribute): New.
> >         * tree-object-size.c (alloc_object_size): Use alloc_size
> >         attribute, if available.
> >
> >         * testsuite/gcc.dg/attr-alloc_size.c: New.
>
> Good idea, I just wonder if it wouldn't be better to extend the malloc
> attribute for this instead (i.e. it could have no arguments as it
> does now, or one or two as your alloc_size argument does).

I think we should not overload the malloc attribute, as we would be
unable to handle realloc in this case.

> Or are there functions which should not have malloc attribute set
> and can have alloc_size?

realloc comes to my mind.  Possibly no others.

Richard.



More information about the Gcc-patches mailing list