This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50184] New: Segmentation fault. Copy Constructor.
- From: "EugeneSm at yandex dot ru" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 25 Aug 2011 09:00:31 +0000
- Subject: [Bug c++/50184] New: Segmentation fault. Copy Constructor.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50184
Bug #: 50184
Summary: Segmentation fault. Copy Constructor.
Classification: Unclassified
Product: gcc
Version: 4.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: EugeneSm@yandex.ru
#include <iostream>
#include <map>
using namespace std;
class CData
{
class CItem
{
public:
string m_str1;
};
public:
map<string, CItem> m_map;
int m_nWaitTime2ReadSS;
int m_eQueueOrderType;
//- Data ---------------
bool m_bDFRead;
std::string m_strDFName;
int m_nDFLoopCount;
int m_nDFLoopTimeout;
int m_nDFMsgTimeout;
};
class A
{
public:
CData func()
{
CData data;
data.m_map["Test"].m_str1 = "Data";
return data;
}
};
class B : public CData
{
public:
template <class T>
B(T& a)
: CData(a.func())
{
map<string, CItem>::iterator it = m_map.begin();
for (; it != m_map.end(); it++)//In this place m_map.end() returns
wrong value as result I get segmentation fault.
//I noticed that copy constructor when I added one into CData is never called.
{
cout << (*it).first<< " "<<(*it).second.m_str1<<"\n";
}
cout << "GOOD"<<"\n";
}
};
int main()
{
A a;
B b1(a);
return 0;
}
Result of this code is Segmentation fault.