__attribute__ ((malloc)) semantics?
Martin Dickopp
firefly-mail@gmx.net
Fri May 9 23:48:00 GMT 2003
Hi,
I'm a bit confused what the effect of __attribute__ ((malloc)) is.
The GCC manual says:
The `malloc' attribute is used to tell the compiler that a function
may be treated as if it were the malloc function. The compiler
assumes that calls to malloc result in a pointers that cannot
alias anything. This will often improve optimization.
What does is mean to treat a function as if it were the malloc function,
other than assuming that the returned pointer does not alias anything?
E.g., would it be safe to use __attribute__ ((malloc)) on the following
function?
int *foo (void) { static int i; return &i; }
Thanks,
Martin
More information about the Gcc-help
mailing list