[PATCH] doc: discourage use of __attribute__((optimize())) in production code

Trevor Saunders tbsaunde@tbsaunde.org
Mon Dec 14 18:57:00 GMT 2015


On Mon, Dec 14, 2015 at 05:40:57PM +0100, Markus Trippelsdorf wrote:
> On 2015.12.14 at 11:20 -0500, Trevor Saunders wrote:
> > On Mon, Dec 14, 2015 at 10:01:27AM +0100, Richard Biener wrote:
> > > On Sun, Dec 13, 2015 at 9:03 PM, Andi Kleen <andi@firstfloor.org> wrote:
> > > > Markus Trippelsdorf <markus@trippelsdorf.de> writes:
> > > >
> > > >> Many developers are still using __attribute__((optimize())) in
> > > >> production code, although it quite broken.
> > > >
> > > > Wo reads documentation? @) If you want to discourage it better warn once
> > > > at runtime.
> > > 
> > > We're also quite heavily using it in LTO internally now.
> > 
> > besides that does this really make sense?  I suspect very few people are
> > using this for the fun of it.  I'd guess most usage is to disable
> > optimizations to work around bugs, or maybe trying to get a very hot
> > function optimized more.  Either way I suspect its only used by people
> > with good reason and this would just really iritate them.
> 
> Well, if you look at bugzilla you'll find several wrong code bugs caused
> by this attribute, e.g.: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59262

is that wrong code? it looks to me like somebody thinks its missed
optimization, and personally I'd say its not a bug just not fully
expected behavior.

> Also Richi stated in the past (I quote):
> »I consider the optimize attribute code seriously broken and
> unmaintained (but sometimes useful for debugging - and only that).«
> 
> https://gcc.gnu.org/ml/gcc/2012-07/msg00201.html

I'm certainly not recommending its use, and noting in docs that its
results can be suprising seems reasonable, but runtime warnings seems
likely to annoy users.

Trev

> 
> -- 
> Markus



More information about the Gcc-patches mailing list