Map memory corruption in template style function call

I have a strange memory corruption to a std::map when using the std::map.find function and was hoping to get some advice. I am using 64-bit windows XP and compiling my code with ICL to generate 64-bit DLLs.

Code snippet:

my_instance_ptr has a member std::map my_map.

my_instance_ptr->get ("name") leads to a function call to my_map.find ("name"). This my_map.find call works correctly and results a NIL since the map is empty.

I subsequently call a function
my_instance_ptr->register <MyType> ("name") leads to a function call to my_map.find ("name"). This my_map.find call throws an exception while searching through the tree even though the map is empty.

The difference between the prototype "get" and "register" is

My_Obj_Type * get (std::string name_spec);

template <typename type>
My_Obj_Type *
register (std::string name_spec = "", int temp = 0);

I did try to remove the default arguments from the register function but that did not change the behavior and the my_map.find still throws an exception. I appreciate any comments/suggestions that you may have.

Thanks,
AD

map::find() doesn't return NULL (if that's what you mean by "results a NIL") when it doesn't find what it's looking for. It returns an iterator to one past the last element (map.end()).

And be careful using register as an identifier, as it's a keyword.
Topic archived. No new replies allowed.