-frepo vs. Borland model

Joe Buck jbuck@synopsys.com
Tue Sep 16 08:59:00 GMT 1997


I wrote:
> > There have been vast improvements in templates.  The main missing feature
> > (as far as I'm concerned), template member functions, has just been added
> > to the egcs snapshots.

Yotam writes:
> Indeed great improvement! Comparing the object sizes:
> 
> telaviv:951> cat avi.cc
> #include <vector>
> int vi(const vector<int>& a, int i)
> {
>    return a[i];
> }
> telaviv:952> g++ -c -O2 avi.cc; ls -l avi.o
> -rw-r--r--   1 yotamm   products     3760 Sep 15 18:13 avi.o
> telaviv:953> egcs++ -c -O2 avi.cc; ls -l avi.o
>  .... annoying warning messages ...
> -rw-r--r--   1 yotamm   products     1420 Sep 15 18:13 avi.o

The size improvements are mainly due to two things I did not mention
above: the new implementation does not instantiate unneeded templates
(the old one would instantiate everything for a whole class); the
new implementation can inline even the first instantiation of a template
(and yes, inlining *reduces* codesize when the function just returns
one variable or class member or directly calls another function).





More information about the Gcc mailing list