Hi!
I've analyzed what's going on with avifile's filter.cpp and recent
gcc-2.96-RH:
g++ uses an heuristic to find out whether to output inline function bodies
or not. This heuristic is the same in g++ 2.95.x, 2.96-RH, I don't have egcs
sources unpacked so I cannot tell whether it was the case already then.
Part of this heuristic is that if the current source module does not define
body of first non-inline non-pure virtual method (if any), it is considered
to only import a class (thus no virtual tables etc. and no inline bodies of
class methods) - it expects that the inline bodies will be defined in the
module which exports that class (= provides implementation for it).
This heuristic is usually right, unfortunately does not work in this exact
case, where an inline method is not defined at all in the exporting module
but in some other one.
The only difference between 2.95.x and 2.96-RH in this case is that gcc
shipped in Red Hat 7.1 distribution does inline throttling a little bit
earlier in this case (unlike 2.95.x where inlining is done on RTL it does
inlining on TREEs and so has also guess how many resulting RTL instructions
will be emitted for each TREE statement (the guess is 10)).
If you make Mpegtoraw::generate() somewhat longer, g++ 2.95.x will fail the
same way (have tried that).
I'm not sure how expensive would be to detect this case in g++ (ie. detect
whether body is defined in a different header than the class (that's not
hard) but keep that information till end of unit compilation).
The source looks standard compliant in this regard (as generate() is not
used anywhere outside of filter.cpp it does not violate [basic.def.odr]/3),
though as mentioned above it works in g++ 2.95.x only by pure luck.
Anyway, if I can suggest some solution for avifile:
a) don't use the "inline" keyword on Mpegtoraw::generate() and the other
problematic ones - it is a huge function and you save nothing by inlining
it
b) detect if g++ supports -finline-limit= option, if it does, pass
-finline-limit=20000 (with this filter.cpp is ok) or higher (the default
is 10000)
c) include filter.cpp and filter2.cpp into mpegtoraw.cpp (or copy it there,
does not matter)
d) define the inline methods in the header together with the class
c) and d) have one drawback though - even if generate() will be inlined,
there will be its body output from the mpegtoraw.cpp module - of course
-Wl,--gc-sections could cure this.
Jakub
_______________________________________________
Avifile mailing list
[EMAIL PROTECTED]
http://prak.org/mailman/listinfo/avifile