I have the following:
- A library called toto.so where the object Toto is implemented:
class Toto
{
        public:
                Toto();
                static Toto *instance() { return self; }

        private:
                static Toto *self;
};

- A main.cpp linked against toto.so:
int main()
{
    Toto tmp;
    std::cout << "Main: Toto::instance() == " << tmp.instance() << std::endl;
    return 0;
}

If I build everything like this:
g++ -shared -fPIC -Wl,--dynamic-list-cpp-typeinfo toto.cpp -o libtoto.so
g++ -Wl,--dynamic-list-cpp-typeinfo main.cpp -L. -ltoto

The toto::instance() function returns 0 in the main function.

However, if I build without --dynamic-list-cpp-typeinfo, the toto::instance()
function returns the correct value.

I compiled natively on Linux I386 and I cross compiled for ARM. 
I got the same results on both architectures.

-- 
           Summary: Dynamic-list-cpp-typeinfo doesn't handle correctly
                    static variables in a class
           Product: binutils
           Version: 2.17
            Status: NEW
          Severity: critical
          Priority: P1
         Component: ld
        AssignedTo: unassigned at sources dot redhat dot com
        ReportedBy: glazzara at gmail dot com
                CC: bug-binutils at gnu dot org
GCC target triplet: Any


http://sourceware.org/bugzilla/show_bug.cgi?id=3713

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to