Help with STL

John Fine johnsfine@verizon.net
Thu Sep 11 14:41:00 GMT 2008


The problem is in the line

(*neigh) = &(changed_atms[changed_atms.size() -1]);

You are taking the address of an element of a vector and keeping that 
address long past the time it becomes invalid.

As soon as the vector grows, that address becomes invalid.

Even if the vector didn't grow, I think you are keeping the address 
after the whole vector goes out of scope.  But I'm not sure of that.  I 
am sure you are using the address while the vector is still in scope, 
but after it may have grown.  That's bad enough.




More information about the Gcc-help mailing list