Skip to main content

Thread: why would std::string assignment operator fail?


i call function
code:
themap[x][y].moveuniton('m', c, "a merchant", unitpointer(&(merchantlist[merchantnum])));
which looks this
code:
void tile::moveuniton(char g, int c, string d, unitpointer unit) {     bggraphic = graphic;     graphic = g;     bgcolorpair = colorpair;     colorpair = c;     bgdescription = description;     description = d;     occupyingunit = unit; }
and segmentation fault. gdb tells me problem bgdescription = description. bgdescription data member of tile. error is:

code:
#0 0x7ffff773019a    ??() (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??) #1 0x7ffff77315c6    std::string::assign(std::string const&) () (/usr/lib/x86_64-linux-gnu/libstdc++.so.6:??) #2 0x4032ec    tile::moveuniton(this=0x7ffffffa33c0, g=77 'm', c=5, d=..., unit=...) (/home/mike/desktop/klepto/tile.cpp:13) #3 0x40263c    player::hiremerchant(this=0x7ffffffa2e80, c=5, themap=0x7ffffff1a300) (/home/mike/desktop/klepto/player.cpp:35) #4 0x404246    main(argc=1, argv=0x7fffffffe268) (/home/mike/desktop/klepto/main.cpp:265)
the code worked fine until changed data member occupyingunit type merchant* unitpointer. in advance.

are running off end of array when index x , y?

if bgdescription not initialised string object, happen when try copy string (e.g. it's going try free old string data, garbage pointer).


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] why would std::string assignment operator fail?


Ubuntu

Comments

Popular posts from this blog

Adobe Acrobat Pro , Terminal Server Use

Thread: transmission-daemon isn't playing nice: "409: Conflict"

Thread: gpg: Conflicting Commands