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]

Re: Default constructors & arrays


> 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


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