This is the mail archive of the gcc-help@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: function attributes on function pointers


Kalle Olavi Niemitalo <kon@iki.fi> writes:

> I tried to work around that limitation by defining a function
> that has the malloc attribute and then calls the function pointer:

> However, "gcc (Debian 4.4.5-8) 4.4.5" -O2 on x86_64 generates
> code that assumes the pointers may alias:

> If I remove the definition of call_my_malloc, so that gcc cannot
> inline it, then gcc respects the malloc attribute:

> I wonder if this qualifies as a missed-optimization bug,
> and whether later versions of gcc do the same.

While one could make an argument that this is a missed-optimization (and
I would expect that later versions of gcc act the same way), I think the
correct, and in fact simpler, fix is to make these shenanigans
unnnecessary, not to try to optimize them better.

Ian


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