Bug 20942

Summary: binutils break C++ in GCC 2.95.x and GCC-current
Product: Base System Reporter: pfeifer <pfeifer>
Component: gnuAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.1-RELEASE   
Hardware: Any   
OS: Any   

Description pfeifer 2000-08-30 14:00:00 UTC
Apparently binutils as of 4.1-RELEASE break static constructors in C++
for GCC 2.95.x and GCC-current. Both work fine (w/o FreeBSD patches) on
FreeBSD 3.x and also GCC 2.95.2 as shipped with 4.1-RELEASE is fine.

I assume that there is a problem (change) in binutils on 4.1-RELEASE that
causes this breakage and that has been fixed (also made) in the imported
version of GCC?

Fix: 

1. Fix (the local copy?) of binutils.
2. If it is a GCC bug (which I don't believe) submit the change back
   to the GCC maintainers.
How-To-Repeat: Compile and run the following small C++ program with either GCC 2.95.2
(original version, w/o FreeBSD patches) or GCC-current and you'll get
a core dump as the static constructor is not invoked.

GCC as shipped with 4.1-RELEASE is not affected.

-------- cut --------
#include <map>
#include <iostream>

struct NAMESTABLE
    {
    map<int,int> lookup;

    NAMESTABLE()
        : lookup()
        {
        cout << "constructor" << endl;
        }

    void add(const char *s, const int &item)
        {
        cout << s << endl;
        lookup.insert(pair<int,int>(item,0));
        }
    };

NAMESTABLE q;

int main() {
    NAMESTABLE p;
    p.add("auto",1);
    q.add("static",1);
    }
Comment 1 pfeifer 2000-11-05 08:17:53 UTC
Please close this PR. It is a duplicate of 20966 and originally
was ``lost'' by GNATS so that sheldonh asked me to file it again
(which led to 20966).

This weekend 20942, after a few weeks(!) 20942 finally appeared in
GNATS, but 20966 has been worked on already.

Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/
Comment 2 Johan Karlsson freebsd_committer freebsd_triage 2000-11-05 12:30:32 UTC
State Changed
From-To: open->closed

Closed at originators request.