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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
            Summary|[4.6 Regression] Multiple   |[4.6 Regression] virtual
                   |Inheritance - Covariant     |Inheritance - Covariant
                   |Virtual Function - Segfault |Virtual Function - Segfault

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-02-25 
13:07:26 UTC ---
minimal testcase with no namespaces or multiple inheritance

the segfault goes away if Ent is an empty class or if virtual inheritance isn't
used


struct Base
{
    virtual ~Base(){}

    virtual Base& This() { return *this; }
};


struct Ent : virtual Base
{
    void *m_Body;

    Ent& This() { return *this; }

    virtual Ent& body()
    {
        return This();
    }

};


struct Msg : virtual Ent
{
    Msg()
    {
        body();
    }

    Msg& This() { return *this; }
};

int main()
{
    Msg m;

    return 0;
}

miscompiled by gcc-4.6-20110219 snapshot

Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x00000000004007ff in Ent::body (this=0x7fffffffe598) at bug.cc:17
#2  0x00000000004009ca in Msg::Msg (this=0x7fffffffe590,
    __in_chrg=<value optimized out>, __vtt_parm=<value optimized out>)
    at bug.cc:27
#3  0x0000000000400719 in main () at bug.cc:35

Reply via email to