Hi,
I'm using g++ (GCC) 3.3.3 20031206 (prerelease) (Debian). I don't fully
understand the behavior of the compiler -O2 with the C++ program (the
smallest I could produce showing the "problem") attached to this email.
The zero() function gets compiled and tail-optimized, fine. However,
the
A::zero() and B::zero() static member functions, although they amount
in
combination at the same code of zero(), are _not_ tail optimized. At
first I thought templates prevent the compiler from tail-optimizing,
but
if I make A::zero() more trivial (turn the #if 1 into an #if 0) the
tail
optimization shows up.
Is there anything that prevents tail optimization with #if 1? If not,
is
this to be considered a possible improvement for gcc or it is just too
specific/hard to implement?