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]
Other format: [Raw text]

two constructor copies in object file



I compiled the following code with: g++-3.1 -nostdinc -nostdinc++ -c
g++ is snapshot 20020114 with threads disabled.

extern "C" char* _end;

class boot_obj
{
protected:
    static char* top_of_heap;

    boot_obj() throw(); 
    boot_obj(boot_obj& x) throw(); 
    void*  boot_alloc(unsigned int) throw();  
};


boot_obj::boot_obj() throw ()
{
   static bool started = false;
   if (!started) 
   {
       top_of_heap = reinterpret_cast<char*>((reinterpret_cast<unsigned int>(_end) + 0x01) & ~0x01);
       started = false; 
   }
}

boot_obj::boot_obj(boot_obj& x) throw ()
{

}

void* boot_obj::boot_alloc(unsigned int sz) throw ()
{
    void* ret = top_of_heap;
    top_of_heap += ((sz + 0x01) & ~0x01);
    return ret;  
} 

nm --demangle yeilds the following:


0000005c T boot_obj::boot_alloc(unsigned)
         U boot_obj::top_of_heap
00000054 T boot_obj::boot_obj(boot_obj&)
00000026 T boot_obj::boot_obj()
0000004c T boot_obj::boot_obj(boot_obj&)
00000000 T boot_obj::boot_obj()
00000000 d boot_obj::boot_obj()::started
         U _end

Why are the constructors created twice?
and why is the static member undefined?


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