This is the mail archive of the gcc@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: std::pow implementation


On Jul 30, 2003, Gabriel Dos Reis <gdr@integrable-solutions.net> wrote:

> I gave a quote of the purpose of inline in C++.

There is indeed one obvious use for inline, namely accessor
functions.  There are several other uses that are not that obvious, in
which the programmer can't possibly tell whether it's profitable to
inline the function at all locations where it is called, because
further optimizations enabled by inline substitution depend on the
arguments passed to the function.

Therefore, inline the way you describe it, is useful only for
functions that are *always* profitable to inline.  Any function that
might or might not be profitable to inline should not be declared
inline, and the compiler would never inline it.  This sounds silly to
me.  Why not let the user tell the compiler `hey, look, this function
is probably worth trying to inline', but letting the compiler decide
whether it's actually profitable or not, depending not only on the
context, but also on machine-dependent features?

You're arguing for a definition that was created 20 years ago, against
one that was come up with after at least 15 years of accumulation of
experience on the subject, just because you see one case in which that
old definition *might* suit some particular coding style better than
the new definition, even though, if the new definition is implemented
correctly, it can't possibly produce worse code?

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist                Professional serial bug killer


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