I have 2 vectors of strings. I'm passing them to a function by reference with one being const inside the function. I add some strings to the non-const vector and come out of the function. For some reason when the vector that was not const goes out of scope it throws exceptions when trying to deallocate the strings. Here is an example.
It doesn't seem matter what text is in the vector. I've tried rearranging the order of the string but it always seems to break on the second or third element. I've tried doing a pop_back() from the end of the vector and it goes fine until it gets up toward the beginning of the vector.
void func1(const vector<string> &vector1, vector<string> &vector2)
//it doesn't matter what happens to vector1 because it is working properly
//disregard it for this example
vector2.clear(); //to make sure it's empty
//push on some random data for this example
//I'm actually grabbing some text from an access DB
for (int i = 0; i < 8; i++)
//do something with vector 2 now, only reading from it though, no writing
//I was letting them go out of scope but I couldn't tell which vector was having trouble
//The problem manifests when clear() is called as well
vector2.clear(); //here is where the program breaks
Just for reference I'm using Visual C++ 6.0 (ugh) and vector1 destroys just fine. The actual exception is happening when in the std::string's deallocate function. It is throwing an assert on IsValidHeapPointer.
Thanks in advance for any help.