This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Default constructors & arrays
- To: igord at research dot nj dot nec dot com
- Subject: Re: Default constructors & arrays
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Tue, 19 May 1998 09:07:12 +0200
- CC: egcs at cygnus dot com
- References: <199805182104.RAA10234@borg9.nj.nec.com>
> Can somebody clarify to me why egcs generates different code for
> built-in int and defined Int class? I though giving an empty default
> constructor would get rid of constructor call .. am I missing
> something well known?
This is true, in a sense: It is not calling the constructor.
It still loops over the array, not calling them, though :-(
If class Int had virtual functions, it would need to initialize the
__vt fields of the array elements. Since this is not the case, the
constructor and destructor loops turn out empty.
If you think this case important enough to deserve optimization, I
suggest that you look into gcc/g++ to introduce such optimization.
Maybe you find some interesting generalizations of your sample code in
the process.
Martin