vector<int> bug?

Theodore C. Belding Ted.Belding@umich.edu
Tue Feb 10 15:15:00 GMT 1998


It looks like I repeated a mistake I made several weeks ago, regarding
overload resolution and the new C++ Standard.

The following snippet results in compiler errors:

vector<int> table;
table.insert(table.end(), 2, 0);

However, the following compiles fine:

vector<int> table;
table.insert(table.end(), 2u, 0);
                          ^^^

Due to the new standard, it seems that the "2" is being interpreted as int
during overload resolution, rather than unsigned int, which is what I had
intended.

I wish the errors were less cryptic, but it seems to be my fault again. :)
Thanks!
-Ted

At 9:59 PM -0500 2/9/98, Theodore C. Belding wrote:

>eg++  -pipe -O0 -fno-exceptions -fno-rtti   -Wall -Wno-return-type
>-Wno-uninitia
>lized   -I../libGAWUtil-src -I../libGAWRNG-src
>-I../../unix/src/unix-libGAWUtil-
>src -I../libHDF-src -I.     -c CanonGABlockDivCollector.cc -o
>CanonGABlockDivCol
>lector.o
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_vector.h:171: no type
>named `it
>erator_category' in `int'
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_vector.h:171: no type
>named `va
>lue_type' in `int'
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_vector.h:171: no type
>named `di
>fference_type' in `int'
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_vector.h:171: no type
>named `po
>inter' in `int'
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_vector.h:171: no type
>named `re
>ference' in `int'
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_iterator.h: In function
>`{error
>} iterator_category<int>(const int &)':
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_iterator.h:126:
>return-type `{e
>rror}' is an incomplete type
>/s/users/streak/local/egcs-1.0.1/include/g++/stl_iterator.h:126: confused
>by ear
>lier errors, bailing out
>make: *** [CanonGABlockDivCollector.o] Error 1

--
Ted Belding                               Ted.Belding@umich.edu
University of Michigan Program for the Study of Complex Systems
http://www-personal.umich.edu/~streak/





More information about the Gcc-bugs mailing list