This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/52032] Function and class attributes should optionally take a bool parameter enabling them
- From: "joseph.h.garvin at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 30 Jan 2012 21:13:37 +0000
- Subject: [Bug c++/52032] Function and class attributes should optionally take a bool parameter enabling them
- Auto-submitted: auto-generated
- References: <bug-52032-4@http.gcc.gnu.org/bugzilla/>
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.