Bug 901 - STL vector with initializer problem.
STL vector with initializer problem.
Status: CLOSED CURRENTRELEASE
Product: Red Hat Linux
Classification: Retired
Component: egcs (Show other bugs)
5.2
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Preston Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-01-20 15:59 EST by swift
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 1999-03-22 15:25:48 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description swift 1999-01-20 15:59:55 EST
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 15:25:59 EST
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.

Note You need to log in before you can comment on or make changes to this bug.