This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/50184] Segmentation fault. Copy Constructor.


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50184

Vittorio Zecca <zeccav at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |zeccav at gmail dot com

--- Comment #4 from Vittorio Zecca <zeccav at gmail dot com> ---
I still have the same bug in g++ 5.2.0 in the following:

#include <map>
#include <string>
using namespace std;

struct CData
{
    struct CItem
    {
        string m_str1;
    };

    map<string, CItem>  m_map;

    std::string         m_strDFName;
    int                 m_nDFMsgTimeout;
};

    CData func()
    {
        CData data;
        data.m_map["Test"].m_str1 = "Data";
        return data;
    }

class B : public CData
{
public:
    B()
        : CData(func())
    {
        std::string s;
        map<string, CItem>::iterator it = m_map.begin();
        for (; it != m_map.end(); it++) // loops past the end
        {
            s += it->second.m_str1 + it->first;;
        }
    }
};

int main()
{
    B b1;
    return 0;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]