I get the following when I run my program through valgrind
==29852== Invalid read of size 8
==29852== at 0x4EDEA50: std::_Rb_tree_increment(std::_Rb_tree_node_base const*) (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21)
==29852== by 0x414EEA: std::_Rb_tree_const_iterator<std::pair... >::operator++() (stl_tree.h:284)
==29852== by 0x4268CF: Tree::removeConstantsPair(std::set...) (Tree.h:65)
==29852== by 0x4239C4: yy_reduce(yyParser*, int) (parser.y:251)
==29852== by 0x425F6D: Parse(void*, int, Token*, Tree*) (parser.c:1418)
==29852== by 0x404837: main (main.cpp:95)
Line 65 in Tree.h is
inline void removeConstantsPair(set<pair<string, string>>& vec){
set<string>::iterator itr;
for(auto &v : vec){ //This is line 65
itr = domainList.find(v.first);
if(itr != domainList.end())
vec.erase(v);
}
}
However the Leak summary says that there is no memory that is lost. From what I understand invalid read happens if I am reading from a memory that has been freed so in my case &vec must have been freed before. My program runs though and does not crash.
Can someone explain why is there a memory read error.
Aucun commentaire:
Enregistrer un commentaire