[Bug c++/52032] Function and class attributes should optionally take a bool parameter enabling them

joseph.h.garvin at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jan 30 21:39:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52032

--- Comment #4 from Joseph Garvin <joseph.h.garvin at gmail dot com> 2012-01-30 21:13:37 UTC ---
That's why I put the severity as enhancement :)

I thought of a better example.

template<bool force_inline>
void __attribute__((always_inline(force_inline))) foo()
{
    // ...
}

Now you can choose whether to force inlining of foo on a per call site basis,
which AFAICT there is no way to do in GCC currently. I don't think template
specialization can accomplish the same -- the best you could do would be
defining a function with a copy pasta of the same code but a different name.
You couldn't have both versions call a common function because the force_inline
parameter would need to apply to it as well.



More information about the Gcc-bugs mailing list