c++/1875: G++ fails compiling simple STL code

fpillet@opteway.com fpillet@opteway.com
Mon Feb 5 07:26:00 GMT 2001


>Number:         1875
>Category:       c++
>Synopsis:       G++ fails compiling simple STL code
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Feb 05 07:26:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Florent Pillet
>Release:        2.97-20000205 CVS
>Organization:
>Environment:
Linux Mandrake 7.2 w/kernel 2.4.1
>Description:
G++ 2.97 has been failing on this simple code for quite some time:

#include <iostream.h>
#include <vector.h>
main ()
{
  vector<char> v;
  for (vector<char>::iterator i = v.begin(); i != v.end(); ++i) {
    cout << *i;
  }
}

Compiling this code produces the following errors:

$ /usr/local/gcc/bin/gcc -c test.cpp -o test.o -v
Reading specs from /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc/configure --with-gcc-version-trigger=/opt/gcc-3.0/gcc/gcc/version.c --host=i686-pc-linux-gnu --prefix=/usr/local/gcc
gcc version 2.97 20010205 (experimental)
 /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/cc1plus -v -D__GNUC__=2 -D__GNUC_MINOR__=97 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__STDC_HOSTED__=1 -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ test.cpp -D__GNUG__=2 -D_GNU_SOURCE -D__GXX_ABI_VERSION=100 -quiet -dumpbase test.cpp -version -o /tmp/ccKSh0Dh.s
GNU CPP version 2.97 20010205 (experimental) (cpplib) (i386 Linux/ELF)
GNU CPP version 2.97 20010205 (experimental) (cpplib) (i386 Linux/ELF)
GNU C++ version 2.97 20010205 (experimental) (i686-pc-linux-gnu)
	compiled by GNU C version 2.97 20010205 (experimental).
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gcc/include/g++-v3
 /usr/local/gcc/i686-pc-linux-gnu/include/g++-v3
 /usr/local/include
 /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/include
 /usr/local/gcc/i686-pc-linux-gnu/include
 /usr/include
End of search list.
test.cpp: In function `int main()':
test.cpp:8: ambiguous overload for `std::__normal_iterator<char*, 
   std::vector<char, std::allocator<char> > >& != std::__normal_iterator<char*, 
   std::vector<char, std::allocator<char> > >' operator
/usr/local/gcc/include/g++-v3/bits/stl_relops.h:47: candidates are: bool 
   std::rel_ops::operator!=(const _Tp&, const _Tp&) [with _Tp = 
   std::__normal_iterator<char*, std::vector<char, std::allocator<char> > >]
/usr/local/gcc/include/g++-v3/bits/stl_iterator.h:1046:                 bool 
   std::operator!=(const std::__normal_iterator<_IteratorL, _Container>&, const 
   std::__normal_iterator<_IteratorR, _Container>&) [with _IteratorL = char*, 
   _IteratorR = char*, _Container = std::vector<char, std::allocator<char> >]
>How-To-Repeat:
See code above in description.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-bugs mailing list