'malloc' attribute?

Chris Lattner sabre@nondot.org
Wed Feb 26 23:24:00 GMT 2003


> 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
> int *foo() __attribute__((malloc));

Err... sorry to respond to myself, but I see the error of my ways:

int * restrict foo();
int *foo2() __attribute__((malloc));

... is the test I intended, and is, in fact, accepted by gcc.  So, is
there any difference between these two declarations?

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/



More information about the Gcc mailing list