This is the mail archive of the 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: behavior of egcs?

Thomas Handler writes:

> calling virtual member functions in the constructor doesn't seem to work

It does work, according to the C++ specification.  When you're running 
the constructor of the A sub-object of an instance of class B, the
object is not a B yet, so virtual dispatch finds A::s methods only.

> Occuring exceptions while creating objects via new in free store give
> memory leaks (section 14.4.4 Stroustrup C++ programming language 3rd ed.
> seems to define this as I would have expected).

I tested this with egcs 1.0.[12], the problem was fixed.

> As an addition the thrown excepetion also causes memory leaks as you can
> see when uncommenting out the marked line in class Exception...

It's not an actual leak (in egcs 1.0.2); it will allocate the memory
only once.  If you run the try/catch block in a loop a thousand times,
you'll get the same memory usage that you get for a single execution,
which proves the exception-handling area is reused.

Alexandre Oliva
Universidade Estadual de Campinas, SP, Brasil

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