This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: 'malloc' attribute?


Chris Lattner <sabre at nondot dot org> writes:

> Apparently C99 doesn't allow declaring a function to return a 'restrict'
> pointer (GCC rejects it at least), but GCC does allow you to attach the
> malloc attribute to a function.  It seems to me that this is the exact
> same information, ie, the following two function prototypes should be
> equivalent:
>
> restrict int* foo();            // Currently rejected with -std=c99

You've got the 'restrict' in the wrong place: try

int * restrict foo();

which attaches the qualifier to the pointer, not the thing it points
to.

I don't know whether or not that's the same thing as attribute malloc.

zw


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]