I am trying to check if a map is empty or not in c++ using a pointer to a map. However, I get a segmentation fault, although the map is not NULL. The code is so simple and here:
void func(std::map<std::string, std::vector<Foo*> >* myMap){
   if(myMap == NULL)
      std::cout << "My map is Null" << std::endl;
   else if(myMap->empty())
      std::cout << "My map is empty" << std::endl;
}
The parameter sometimes may be an uninitialized map. When I executed this code, the result is a segmentation fault. The code skips the if statement, because it does not see myMap as a NULL map. Then, it crashes in myMap->empty() command. It also crashes when I try to call any function of the map, such as clear, begin, size, etc. So, if myMap is not NULL, what kind of reason could it cause to this seg. fault?
 
     
     
    