GCC 3.3 release criteria
Steven Bosscher
s.bosscher@student.tudelft.nl
Tue Feb 25 10:57:00 GMT 2003
Op di 25-02-2003, om 11:13 schreef Richard Earnshaw:
>
> > > For functions marked with the "inline" keyword, as opposed to C++
> > > inline class methods, can anyone give me a reason why we don't treat
> > > the inline keyword as an always_inline attribute?
> >
> > I wholeheartedly second that. If I write "inline" in C I expect that to happen
> > as soon as the optimizer is turned on. If there is room for even more
> > inlining after that, fine.
> > So, for C "inline" should be mapped to "always_inline".
>
> I think the inline keyword should be treated exactly in the same terms as
> the register keyword. That is, as a hint to the compiler. As time goes
> by the inline keyword will become increasingly meaningless, since the
> compiler will be able to do a better job. Forcing the compiler to respect
> inline regardless of the consequences is a mistake.
Yes the compiler will learn to do good inlining. This is one of the
reasons why some people discourage the use of the inline keyword: Just
trust the compiler to do well.
You say that therefore the compiler should only use "inline" as a hint.
I think it is *extra* reason to interpret "inline" as "always_inline".
Especially in C, people that do use "inline" probably have strong
reasons for why they want to see this function be inlined. For example
in the kernel, they want to be able to control and predict what the
compiler does with the code. It this case it is a mistake on the
compiler's part to think it can outsmart man.
Like Franz said, for C++ things are probalby different.
Greetz
Steven
More information about the Gcc
mailing list