http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56050
Bug #: 56050 Summary: g++ compiler confused with virtual functions. Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: triste...@yahoo.com the following example code compiles cleanly when the second-and-third-last lines in the main function are commented out, however when it's uncommented it fails with: a.cpp: In function ‘int main(int, const char**)’: a.cpp:39:7: error: no matching function for call to ‘derived::to()’ a.cpp:39:7: note: candidate is: a.cpp:30:7: note: virtual void derived::to(std::map<std::basic_string<char>, std::basic_string<char> >) a.cpp:30:7: note: candidate expects 1 argument, 0 provided a.cpp:40:27: error: no matching function for call to ‘derived::from(std::string)’ a.cpp:40:27: note: candidate is: a.cpp:26:7: note: virtual void derived::from(std::map<std::basic_string<char>, std::basic_string<char> >) a.cpp:26:7: note: no known conversion for argument 1 from ‘std::string {aka std::basic_string<char>}’ to ‘std::map<std::basic_string<char>, std::basic_string<char> >’ that was simply from a command line: g++ a.cpp as you can see from the code below the compiler doesn't seem able to differentiate between the virtual functions and the base functions, even though the parameters differ. i think i was expecting the compiler to be able to differentiate between: - "from" functions requiring std::string and std::map<std::string, std::string> - "to" functions requiring void and std::map<std::string, std::string> further, if the error is valid, i think i would expect the compilation to fail regardless of whether the two lines in main are commented out or not, ie: the compiler fails to detect the errors in the classes at compile-time. regards tristen #include <map> #include <string> #include <iostream> class base { public: void from(std::string p_value) { std::cout << p_value << std::endl; } void to() { } virtual void from(std::map<std::string, std::string> p_map) = 0; virtual void to(std::map<std::string, std::string> p_map) = 0; }; class derived : public base { public: void from(std::map<std::string, std::string> p_map) { } void to(std::map<std::string, std::string> p_map) { } }; int main(int, const char**) { derived d; // d.to(); // d.from(std::string("one")); return 0; }