Bug 901

Summary: STL vector with initializer problem.
Product: [Retired] Red Hat Linux Reporter: swift
Component: egcsAssignee: Preston Brown <pbrown>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 5.2   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 1999-03-22 20:25:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description swift 1999-01-20 20:59:55 UTC
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

Comment 1 Preston Brown 1999-03-22 20:25:59 UTC
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.