
I have been pulling my hair out over this bug for a day or two now. Here's the synopsis. I have a boost::any object which is storing a std::string. Any test I do to check if indeed the any object is holding onto a std::string object verifies what I already know. For instance, the following function always returns true for my boost::any object: bool is_string(const boost::any& operand) { return ( operand.type() == typeid(std::string) ); } Also if I just print out the typeinfo information for the boost::any object is also shows that its holding onto a std::string: std::stringstream ss; ss << "any object: " << obj.type().name() << ", a string: " << typeid(std::string).name(); yields, any object: Ss, a string: Ss However, whenever I try and actually cast my object to a string (boost::any_caststd::string(...)), I always get "boost::bad_any_cast: failed conversion using boost::any_cast". Could this possibly be a compiler issue? I saw one other thread where "-fvisibility=hidden" was causing some problems for boost::program_options and std::string. In my situation, I have a library which is responsible for creating those boost::any objects. Then its in a separately compiled library where I am getting the problems.