This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11163] New: Can't pass tolower as a parameter


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11163

           Summary: Can't pass tolower as a parameter
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: cda@freshsources.com
                CC: gcc-bugs@gcc.gnu.org

Hello,

The following program is thought to be conforming by reputable members of the 
C++ standards committee:

// Converts a string to lower case via transform()
#include <algorithm>	// For transform
#include <cctype>	// For tolower
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s("LOWER");
  transform(s.begin(),s.end(),s.begin(), tolower);
  cout << s << endl;  // lower
} ///:~

g++ seems to require a cast, even though the cast is to the exact type of the 
function already:

  transform(s.begin(),s.end(),s.begin(),
            static_cast<int(*)(int)>(tolower));

Do you why g++ 3.2 requires the cast? It seems to be having trouble deducing 
the last argument to transform.

The error message from the first program is:

$ g++ toupper.cpp
toupper.cpp: In function `int main()':
toupper.cpp:9: no matching function for call to `transform(
   __gnu_cxx::__normal_iterator<char*, std::basic_string<char,
   std::char_traits<char>, std::allocator<char> > >,
   __gnu_cxx::__normal_iterator<char*, std::basic_string<char,
   std::char_traits<char>, std::allocator<char> > >,
   __gnu_cxx::__normal_iterator<char*, std::basic_string<char,
   std::char_traits<char>, std::allocator<char> > >, <unknown type>)'

I am running under Cygwin in Windows XP.

Thank you very much.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]