Bug 22070 - including iostream causes lookup of std function to fail when passed into STL algorithm
Summary: including iostream causes lookup of std function to fail when passed into STL...
Status: RESOLVED DUPLICATE of bug 11108
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.4.4
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-14 23:11 UTC by Jason Beardsley
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Beardsley 2005-06-14 23:11:32 UTC
The inclusion of iostream breaks the following program.  A workaround is to define an inline function that calls into tolower() and use it as the last argument to transform().

Code:

#include <cctype>
#include <string>
#include <algorithm>
#include <iostream>

int main()
{
  std::string foo("AbCd");
  std::transform(foo.begin(), foo.end(), foo.begin(), std::tolower);
  return 0;
}

Output:

Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.4/specs
Configured with: ../gcc-3.4.4/configure --prefix=/usr/local --enable-languages=c++
Thread model: posix
gcc version 3.4.4
 /usr/local/libexec/gcc/i686-pc-linux-gnu/3.4.4/cc1plus -E -quiet -v -D_GNU_SOURCE foo.cpp -mtune=pentiumpro -o foo.ii
ignoring nonexistent directory "/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/i686-pc-linux-gnu
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.4/../../../../include/c++/3.4.4/backward
 /usr/local/include
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.4/include
 /usr/include
End of search list.
 /usr/local/libexec/gcc/i686-pc-linux-gnu/3.4.4/cc1plus -fpreprocessed foo.ii -quiet -dumpbase foo.cpp -mtune=pentiumpro -auxbase foo -version -o foo.s
GNU C++ version 3.4.4 (i686-pc-linux-gnu)
	compiled by GNU C version 3.4.4.
GGC heuristics: --param ggc-min-expand=99 --param ggc-min-heapsize=129426
foo.cpp: In function `int main()':
foo.cpp:12: error: 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>)'
Comment 1 Andrew Pinski 2005-06-14 23:15:21 UTC
This is invalid, see PR 11108 which this is a dup of.

*** This bug has been marked as a duplicate of 11108 ***