mardi 10 octobre 2017

Issue in copying a c++ string to a std::string haveing "\x5" stored by default

I've a funstion in C++ ::

class A
{
std::string dm1;
std::string dm2;

Memberfun1(std::string  val1, std::string val2)
{
dm1=val1;
dm2=val2; // UNHANDLED EXCEPTION
...
}

FOr some reason, i"M getting unhandled exception at "dm2=dm1". Not sure why, because, the assigment dm1=val1 which is also a string assignment is working fine. AT the statement dm2=val2 I get unhandled eception and cal stack breaks in msvcr120d.dll and i see it stops at the below line in the file IOSFWD".

static _Elem *__CLRCALL_OR_CDECL copy(_Elem *_First1, const _Elem *_First2,
        size_t _Count)
        {   // copy [_First2, _First2 + _Count) to [_First1, ...)
        return (_Count == 0 ? _First1
            : (_Elem *)_CSTD memcpy(_First1, _First2, _Count));
        }

Here i see,

_First1 has the value "\x5"
_First2 has the value "2017" and
_Count has 4.

Is this any issue ?

Aucun commentaire:

Enregistrer un commentaire