https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81992
Bug ID: 81992 Summary: C++ toupper symbol clash? Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jg at jguk dot org Target Milestone: --- I thought functions can have the same name, because params are different in C++ eg my void tolower(std::string & str) If I rename my function to tolowerstr, it then works. But I get a build error. I had expected not to conflict int toupper( int ch ); http://en.cppreference.com/w/cpp/string/byte/toupper $ g++ -O2 -Wall -Wextra -Wpedantic -o main main.cpp main.cpp: In function ‘void tolower(std::__cxx11::string&)’: main.cpp:23:66: error: no matching function for call to ‘transform(std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::iterator, <unresolved overloaded function type>)’ std::transform(str.begin(), str.end(), str.begin(), ::tolower); ^ In file included from /usr/include/c++/5/algorithm:62:0, from main.cpp:3: /usr/include/c++/5/bits/stl_algo.h:4164:5: note: candidate: template<class _IIter, class _OIter, class _UnaryOperation> _OIter std::transform(_IIter, _IIter, _OIter, _UnaryOperation) transform(_InputIterator __first, _InputIterator __last, ^ /usr/include/c++/5/bits/stl_algo.h:4164:5: note: template argument deduction/substitution failed: main.cpp:23:66: note: couldn't deduce template parameter ‘_UnaryOperation’ std::transform(str.begin(), str.end(), str.begin(), ::tolower); ^ In file included from /usr/include/c++/5/algorithm:62:0, from main.cpp:3: /usr/include/c++/5/bits/stl_algo.h:4201:5: note: candidate: template<class _IIter1, class _IIter2, class _OIter, class _BinaryOperation> _OIter std::transform(_IIter1, _IIter1, _IIter2, _OIter, _BinaryOperation) transform(_InputIterator1 __first1, _InputIterator1 __last1, ^ /usr/include/c++/5/bits/stl_algo.h:4201:5: note: template argument deduction/substitution failed: main.cpp:23:66: note: candidate expects 5 arguments, 4 provided std::transform(str.begin(), str.end(), str.begin(), ::tolower); //g++ -O2 -Wall -Wextra -Wpedantic -o main main.cpp #include <algorithm> #include <string> #include <iostream> void myfunc(int i) { i = 10; std::cout << i; } void myfunc(std::string i) { i = "10"; std::cout << i; } void tolower(std::string & str) { std::transform(str.begin(), str.end(), str.begin(), ::tolower); } int main (void) { std::string caps = "FOO"; tolower(caps); return 0; }