libstdc++/10783: std::vector::reverse_iterator could be smaller

Sylvain.Pion@mpi-sb.mpg.de Sylvain.Pion@mpi-sb.mpg.de
Wed May 14 16:16:00 GMT 2003


>Number:         10783
>Category:       libstdc++
>Synopsis:       std::vector::reverse_iterator  could be smaller
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          pessimizes-code
>Submitter-Id:   net
>Arrival-Date:   Wed May 14 15:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Sylvain Pion
>Release:        3.2, 3.3, 3.4 (2.95 doesn't have the problem, I don't have 3.[01])
>Organization:
>Environment:
Reading specs from ./GCC/Linux-3.2/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.2.3/specs
Configured with: ../gcc-3.2/configure --prefix=/home/spion/GCC/Linux-3.2 --enable-languages=c++
Thread model: posix
gcc version 3.2.3
>Description:
On my 32bit machine,
sizeof(std::vector<>::reverse_iterator) is 8.
Similarly for std::vector<>::const_reverse_iterator.

All other iterators from the STL containers (except deque)
have sizeof 4.

I believe it could be made also 4 bytes if the empty base class optimization applied, but it seems it doesn't.
Is it because there are 2 derivations from the same iterator<...> class ?  Is there a way to fix it ?
>How-To-Repeat:
#include <iostream>
#include <vector>
int main() {
  typedef std::vector<int> V;
  std::cout << "sizeof(iterator) = " << sizeof(V::iterator) << std::endl;
  std::cout << "sizeof(reverse_iterator) = " << sizeof(V::reverse_iterator) << std::endl;
}
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list