jkmcnk / sx-gcc

The GNU Compiler Collection port to NEC SX CPU architecture.
GNU General Public License v2.0
0 stars 2 forks source link

the c++ virtual functions don't work with SX yet #126

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
The c++ program below crashes on SX if compiled with sx-gcc:

{{

#include <stdio.h>

struct PolyBase {
    virtual void Member(){
        printf("I'm PolyBase\n");
    }
};

struct PolyDerived: PolyBase {
    virtual void Member(){
        printf("I'm PolyDerived\n");
    }
};

int main() {

    PolyDerived polyderived;
    PolyBase* ppolybase = &polyderived;

    polyderived.Member();
    ppolybase->Member();
}

}}

The problem must be in the virtual functions because the ordinary
overloaded functions work ok (the example below works fine on SX):

{{

#include <stdio.h>

struct PolyBase {
    void Member(){
        printf("I'm PolyBase\n");
    }
};

struct PolyDerived: PolyBase {
    void Member(){
        printf("I'm PolyDerived\n");
    }
};

int main() {

    PolyDerived polyderived;
    PolyBase* ppolybase = &polyderived;

    polyderived.Member();
    ppolybase->Member();

}

}}

Original issue reported on code.google.com by nou...@gmail.com on 21 May 2009 at 3:57

GoogleCodeExporter commented 8 years ago
As it turns out the issue occured due to the bug in SX port of the "gas" 
assembler:
it was unable to add an offset to local symbol. With the r210 of sx-binutils, 
the
virtual functions work fine.

Original comment by nou...@gmail.com on 25 May 2009 at 5:16