public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/50184] New: Segmentation fault. Copy Constructor.
@ 2011-08-25  9:02 EugeneSm at yandex dot ru
  2011-08-25  9:16 ` [Bug c++/50184] " EugeneSm at yandex dot ru
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: EugeneSm at yandex dot ru @ 2011-08-25  9:02 UTC (permalink / raw)
  To: gcc-bugs

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-08-24 12:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25  9:02 [Bug c++/50184] New: Segmentation fault. Copy Constructor EugeneSm at yandex dot ru
2011-08-25  9:16 ` [Bug c++/50184] " EugeneSm at yandex dot ru
2011-08-25 10:24 ` redi at gcc dot gnu.org
2011-08-25 11:14 ` redi at gcc dot gnu.org
2015-08-24 12:07 ` zeccav at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).