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: [I don't think it's off-topic at all] Linking speed for C++


On Thu, 31 May 2001, Fergus Henderson wrote:
> I haven't seen the code for KStaticDeleter, but I'll bet that it
> refers to a global or static member variable which contains the list of
> objects to be deleted.

One could think, so, yes.  But besides that -fPIC for the program didn't
help, this is also not the case, it just hold some normal class members,
the addition (and removing) to the global list is done through static
member functions of another class, and the private var which is changed
there (which indeed is static), isn't accessed from outside at all.  (As I
said, objdump revealed no R_386_COPY relocs besides RTTI and vtables).

This is KStaticDeleter without comments:
class KStaticDeleterBase {
    virtual void destructObject() = 0;
template<class type> class KStaticDeleter : public KStaticDeleterBase {
    KStaticDeleter() { deleteit = 0; }
    type *setObject( type *obj, bool isArray = false) {
        deleteit = obj;
        array = isArray;
        if (obj)
        return obj;
    virtual void destructObject() {
        if (array)
           delete [] deleteit;
           delete deleteit;
        deleteit = 0;
    virtual ~KStaticDeleter() {
    type *deleteit;
    bool array;

This should be sane.  You can see it here, if interested:

> For static members of template classes, things may get more complicated,
> especially if the template class is instantiated with the same type from
> two different shared object files.

This is something which I also thought about.  template with the same
params, but instatiated in different DSOs.  Hmm, -Bsymbolic shouldn't make
a difference, as long as no static data is involved in the template.


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