This is the mail archive of the gcc-bugs@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]

[Bug c++/30679] New: One RTTI bug in g++(4.1.0) .


I write a test program .
//
#include <stdio.h>
#include <stdlib.h>

#include <iostream>

//TestA
class TestA;
class TestB;


class TestA
{
public:    
    TestA()
    {
    }
    virtual ~TestA()
    {
    }
protected:    
    int abc_;
public:
    //
    static void Instance(TestA *instance)
    {
        instance_ =  instance;
    }
    //
    static TestA *Instance()
    {
        return instance_;
    };
    virtual void Output()
    {
        std::cout<<"Test A."<<std::endl;
    }
public:
    //
    static TestA* instance_;
};

TestA* TestA::instance_ = NULL;

class TestB :public TestA
{
public:    
    TestB()
    {
    }
    virtual ~TestB()
    {
    }
    virtual void Output()
    {
        std::cout<<"Test B."<<std::endl;
    }
protected:     
    int def_;
public:
    //
    static TestB *Instance()
    {
        return dynamic_cast<TestB *> (TestA::Instance());             
    };
};


int main(int argc,char *argv[])    
{
    TestA::Instance(new TestB());
    TestB::Instance()->Output();
    return 0;
}

But program code dump when running. GDB out info :
(gdb) where
#0  0x08071000 in ?? ()
#1  0x0804a140 in __dynamic_cast (from=0x80524b0, to=0x804dae0 <typeinfo for
TestA>, require_public=134535884, address=0x0, 
    sub=0xb7efbb90 <_dl_fini>, subptr=0xbf872a40)
#2  0x08049998 in main () at testcfg.cpp:64

I test find ,it core in last line 
<TestB::Instance()->Output();>


I compile it with :
g++ -fvisibility=hidden -fvisibility-inlines-hidden -W -Wall -Wpointer-arith
-O3 -g -pipe    -Wno-strict-aliasing -D_REENTRANT -DACE_HAS_AIO_CALLS
-D_GNU_SOURCE -DTOLUA_RELEASE  -I/usr/local/ACE_wrappers -DACE_HAS_EXCEPTIONS
-D__ACE_INLINE__  -c -frtti -I/data/qqpet2/code/src/commlib
-I/data/qqpet2/code/src/zenlib  -I/usr/local/mysql/include
-I/usr/local/ACE_wrappers  -I/usr/local/sqlite-3.3.6/
-I/usr/local/lua-5.1.1/include  testcfg.cpp -o object/testcfg.o 
g++ -fvisibility=hidden -fvisibility-inlines-hidden -W -Wall -Wpointer-arith
-O3 -g -pipe    -Wno-strict-aliasing -D_REENTRANT -DACE_HAS_AIO_CALLS
-D_GNU_SOURCE -DTOLUA_RELEASE  -I/usr/local/ACE_wrappers -DACE_HAS_EXCEPTIONS
-D__ACE_INLINE__  -frtti -o../../bin/testcfg   ./object/testcfg.o 
-L/data/qqpet2/code/lib  -lcommlib -L/data/qqpet2/code/lib  -lzenlib
-L/usr/local/mysql/lib -lmysqlclient_r -lmygcc -lz
-L/usr/local/ACE_wrappers/lib -lACE  -I/usr/local/sqlite-3.3.6/.libs/ -lsqlite3
-L/usr/local/lua-5.1.1/lib -llua -ltoluapp 

My GCC version is:
Target: i586-suse-linux
Configured with: ../configure --enable-threads=posix --prefix=/usr
--with-local-prefix=/usr/local --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib --libexecdir=/usr/lib
--enable-languages=c,c++,objc,fortran,java,ada --enable-checking=release
--with-gxx-include-dir=/usr/include/c++/4.1.0 --enable-ssp --disable-libssp
--enable-java-awt=gtk --enable-gtk-cairo --disable-libjava-multilib
--with-slibdir=/lib --with-system-zlib --enable-shared --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --without-system-libunwind --with-cpu=generic
--host=i586-suse-linux
Thread model: posix
gcc version 4.1.0 (SUSE Linux)


-- 
           Summary: One RTTI bug in g++(4.1.0) .
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sailzeng at tencent dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30679


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