Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
string passed by value deleted before usage?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="nusch, post: 4093869"] I've problem with mini version control system, quickly reviewing - class Repository has list of pointers to class Revision, class Revision has map<string, Patch*> which maps filename to patch. Patch derrives from File, File has vector<string> lines. Here all the files, sory but I can't seperate the problem main.cpp [URL]http://pastebin.com/f83YA1G6[/URL] file.h [URL]http://pastebin.com/0gUiRwz6[/URL] repo.h [URL]http://pastebin.com/RxX94RXJ[/URL] file.cpp [URL]http://pastebin.com/7wrQrBtn[/URL] repo.cpp [URL]http://pastebin.com/wwkUJ1nk[/URL] revision.h [URL]http://pastebin.com/nTMu9yRx[/URL] revision.cpp [URL]http://pastebin.com/aq5J29Cg[/URL] LongestCommonSubsequence.hpp [URL]http://pastebin.com/HHmKmCF1[/URL] Whole logic seems to be ok, I've locked copy constructor as explicit to prevent temporary objects, all objects are created by new, although somewhat some memory is deleted before (file.cpp line 200) void File::add_line(string line) { lines.push_back(line); } valgrind shows that info: ==29517== Invalid read of size 8 ==29517== at 0x405678: std::vector<std::string, std::allocator<std::string> >::push_back(std::string const&) (stl_vector.h:735) ==29517== by 0x4037AE: File::add_line(std::string) (file.cpp:200) ==29517== by 0x40C32C: Revision::parse() (revision.cpp:35) ==29517== by 0x40944D: Repo::load() (repo.cpp:65) ==29517== by 0x409818: Repo::commit(std::string) (repo.cpp:109) ==29517== by 0x40970E: Repo::commit() (repo.cpp:97) ==29517== by 0x408997: main (main.cpp:58) ==29517== Address 0x10 is not stack'd, malloc'd or (recently) free'd ==29517== ==29517== ==29517== Process terminating with default action of signal 11 (SIGSEGV) ==29517== Access not within mapped region at address 0x10 ==29517== at 0x405678: std::vector<std::string, std::allocator<std::string> >::push_back(std::string const&) (stl_vector.h:735) ==29517== by 0x4037AE: File::add_line(std::string) (file.cpp:200) ==29517== by 0x40C32C: Revision::parse() (revision.cpp:35) ==29517== by 0x40944D: Repo::load() (repo.cpp:65) ==29517== by 0x409818: Repo::commit(std::string) (repo.cpp:109) ==29517== by 0x40970E: Repo::commit() (repo.cpp:97) ==29517== by 0x408997: main (main.cpp:58) It's points line with push_back, but if I passing string by value what can cause that the string inside function is deleted ? Or what line in backtrace is wrong? [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
string passed by value deleted before usage?
Top