Hi, I've encountered an odd problem with compiling legacy code that uses STL. I recently upgraded to RH 5.2 {egcs (egcs-2.90.29 980515 (egcs-1.0.3 release))} from RH 5.0 {gcc (version 2.7.2.3)}. The platform is a PC and the processor is a Pentium II. Below is sample code that exercises the problem: #include <vector> int main(void) { vector<int> a(10,0); } Here is a transcript of a compilation session: egcs foo.cc -o foo -lstdc++ /usr/include/g++/stl_vector.h:113: no type named `iterator_category' in `int' /usr/include/g++/stl_vector.h:113: no type named `value_type' in `int' /usr/include/g++/stl_vector.h:113: no type named `difference_type' in `int' /usr/include/g++/stl_vector.h:113: no type named `pointer' in `int' /usr/include/g++/stl_vector.h:113: no type named `reference' in `int' /usr/include/g++/stl_iterator.h: In function `{error} iterator_category<int>(const int &)': /usr/include/g++/stl_iterator.h:126: confused by earlier errors, bailing out Compilation exited abnormally with code 1 at Wed Jan 20 12:06:16 The problem appears to originate with the use of an integer initializer in the constructor. If I use an unsigned int as an initializer like this: {vector<int> a(10,0U);} or even a float like this: {vector<int> a(10,0.0);} then the problem disappears. Similarly, it doesn't matter whether the vector itself is integer, float, or double ... the same compilation error occurs if an integer is used in the initialization constructor. So what bit of nefarious activity is responsible here? Thanks, -dds
This appears to have been a compiler problem. The code fragment compiles without trouble using egcs 1.1.2, which ships with Red Hat Linux 5.9 beta, and will be the default Red Hat Linux 6.0 compiler as well.