[Bug c++/27258] New: ostrstream objects and static variables cause segmentation fault

tim at yeung dot com gcc-bugzilla@gcc.gnu.org
Sat Apr 22 06:27:00 GMT 2006


The follow code (build script also included) causes segmentation fault. 
Problem occurs with g++ 3.4.4 and 3.4.5 on RHEL V4 U2 (x86).  Thanks.

//************ build script ***************

g++ -c staticTestMain.C
g++ -Wno-deprecated -c staticTestA.C
g++ -o staticTest staticTestA.o staticTestMain.o


//************* staticTestA.C ****************

#include <iostream>
using namespace std;
#include <strstream>
#include <typeinfo>
#include "staticTestA.h"

A::A(int i)
  : _i(i)
{
    strstream str;
    str << "Calling " << typeid(*this).name() << "(" << i << ") ...";
    cout << str << endl;
}

void
A::hello()
{
    cout << "Hello, world!" << endl;
}


//************** staticTestA.h ******************

class A {
public:
    A(int i);
    void hello();
private:
    int _i;
};


//**************** staticTestMain.C ******************

#include "staticTestA.h"

static A a(1);

int
main(int argc, char** argv)
{
    a.hello();
}


-- 
           Summary: ostrstream  objects and static variables cause
                    segmentation fault
           Product: gcc
           Version: 3.4.5
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tim at yeung dot com


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



More information about the Gcc-bugs mailing list