problem with vector<unsigned int>
Stephen Vavasis
vavasis@CS.Cornell.EDU
Thu Sep 24 13:03:00 GMT 1998
I think there is a problem with class std::vector<unsigned int> in in
EGCS 1.1. See the test program and error message below. This program
compiles under VC++5.0 and KCC 3.2f (but it didn't compile under KCC
until KAI sent me a patched version of vector).
There was discussion about this very issue on comp.lang.c++.moderated
about one or two months ago. If I remember the discussion correctly,
the standard requires that vector<unsigned int> v(a, b), where a and b
are integers, should be interpreted as: a is the size and b is initial
value, and not as: a and b are iterators.
--- Steve Vavasis
----------------- error message
syn.cs.cornell.edu> g++ -c -v vectest2.cpp
g++ -c -v vectest2.cpp
Reading specs from
/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/specs
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=91 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__
-D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix
-Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__
-Acpu(sparc) -Amachine(sparc) vectest2.cpp /var/tmp/ccARPC9N.ii
GNU CPP version egcs-2.91.57 19980901 (egcs-1.1 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gnu/egcs-1.1b/include/g++
/usr/local/include
/usr/local/gnu/egcs-1.1b/sparc-sun-solaris2.5/include
/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/include
/usr/include
End of search list.
/usr/local/gnu/egcs-1.1b/lib/gcc-lib/sparc-sun-solaris2.5/egcs-2.91.57/cc1plus
/var/tmp/ccARPC9N.ii -quiet -dumpbase vectest2.cc -version -o
/var/tmp/cczYbRPO.s
GNU C++ version egcs-2.91.57 19980901 (egcs-1.1 release)
(sparc-sun-solaris2.5) compiled by GNU C version egcs-2.91.57 19980901
(egcs-1.1 release).
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h: In instantiation of
`iterator_traits<int>':
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h:113: instantiated
from `vector<unsigned int,__default_alloc_template<false,0>
>::vector<int>(int, int)'
vectest2.cpp:7: instantiated from here
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h:113: no type named
`iterator_category' in `int'
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h:113: no type named
`value_type' in `int'
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h:113: no type named
`difference_type' in `int'
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h:113: no type named
`pointer' in `int'
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h:113: no type named
`reference' in `int'
/usr/local/gnu/egcs-1.1b/include/g++/stl_iterator.h: In function
`{error} iterator_category<int>(const int &)':
/usr/local/gnu/egcs-1.1b/include/g++/stl_vector.h:113: instantiated
from `vector<unsigned int,__default_alloc_template<false,0>
>::vector<int>(int, int)'
vectest2.cpp:7: instantiated from here
/usr/local/gnu/egcs-1.1b/include/g++/stl_iterator.h:126: return-type
`{error}' is an incomplete type
/usr/local/gnu/egcs-1.1b/include/g++/stl_iterator.h:126: confused by
earlier errors, bailing out
syn.cs.cornell.edu>
--------------------- offending program
#include <vector>
unsigned int foo(int j) {
using std::vector;
vector<unsigned int> a(j, 0);
for (int i = 0; i < 10; ++i)
a[i] = 1;
return a[0];
}
More information about the Gcc-bugs
mailing list