User account creation filtered due to spam.

Bug 6503 - (Deque) Iterators are not typesafe
Summary: (Deque) Iterators are not typesafe
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.1
: P3 normal
Target Milestone: ---
Assignee: Paolo Carlini
Depends on:
Reported: 2002-04-28 12:26 UTC by Peter Schmid
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Peter Schmid 2002-04-28 12:26:00 UTC
gcc 3.1 rejects the comparison of a deque iterator versus a const deque
iterator. There is no problem when the order of the iterators is
changed. This is a regression with respect to STLport.

3.1 20020427 (prerelease)

System: Linux kiste 2.4.18 #8 Sat Mar 9 15:33:15 CET 2002 i686 unknown
Architecture: i686
SuSE 7.3
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-languages=c,c++,f77,objc

source code tb3.C

#include <deque>
int main()
  using namespace std;

  deque<int> d(2);	
  deque<int>::iterator i;		
  deque<int>::const_iterator ci;

  i = d.begin();		
  ci = d.begin();
  if (i == ci) {}
  if (ci == i) {}							       

g++ -v -W -Wall tb3.C 
Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../gcc/configure --enable-shared --disable-nls --enable-threads=posix --enable-languages=c,c++,f77,objc
Thread model: posix
gcc version 3.1 20020427 (prerelease)
 /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.1/cc1plus -v -D__GNUC__=3 -D__GNUC_MINOR__=1 -D__GNUC_PATCHLEVEL__=0 -D__ELF__ -Dunix -D__gnu_linux__ -Dlinux -D__ELF__ -D__unix__ -D__gnu_linux__ -D__linux__ -D__unix -D__linux -Asystem=posix -D__NO_INLINE__ -D__STDC_HOSTED__=1 -D_GNU_SOURCE -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_i686__ -D__tune_pentiumpro__ tb3.C -D__GNUG__=3 -D__DEPRECATED -D__EXCEPTIONS -D__GXX_ABI_VERSION=100 -quiet -dumpbase tb3.C -W -Wall -version -o /tmp/cc520xTS.s
GNU CPP version 3.1 20020427 (prerelease) (cpplib) (i386 Linux/ELF)
GNU C++ version 3.1 20020427 (prerelease) (i686-pc-linux-gnu)
	compiled by GNU C version 3.1 20020427 (prerelease).
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
tb3.C: In function `int main()':
tb3.C:13: no match for `std::_Deque_iterator<int, int&, int*>& == 
   std::_Deque_iterator<int, const int&, const int*>&' operator
/usr/local/include/g++-v3/bits/stl_deque.h:197: candidates are: bool 
   std::_Deque_iterator<_Tp, _Ref, _Ptr>::operator==(const 
   std::_Deque_iterator<_Tp, _Ref, _Ptr>&) const [with _Tp = int, _Ref = int&, 
   _Ptr = int*]
Comment 1 Paolo Carlini 2002-05-29 02:46:23 UTC
Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-Why: Working on it.
Comment 2 Paolo Carlini 2002-05-29 02:46:23 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Patch applied to trunk:
Comment 3 Paolo Carlini 2002-07-25 04:34:46 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: Fixed for 3.2 and 3.3 together with the related 6604 and
Comment 4 pcarlini 2002-07-25 13:38:13 UTC
From: Paolo Carlini <>
Subject: Re: libstdc++/6503: (Deque) Iterators are not typesafe
Date: Thu, 25 Jul 2002 13:38:13 +0200

 Of course I really meant 6642 not 6604.
 Sorry, Paolo. 

Comment 5 Jakub Jelinek 2002-07-26 23:23:46 UTC
Subject: libstdc++/6503
Date: 26 Jul 2002 23:23:46 -0000

 CVSROOT:	/cvs/gcc
 Module name:	egcs
 Branch: 	gcc-3_2-branch
 Changes by:	2002-07-26 16:23:45
 Modified files:
 	gcc            : ChangeLog 
 	gcc/cp         : ChangeLog 
 	gcc/testsuite  : ChangeLog 
 	libstdc++-v3   : ChangeLog 
 	gcc/cp         : class.c mangle.c rtti.c decl2.c cp-tree.h 
 	gcc/config/i386: i386.c 
 	gcc/config/mips: mips.c 
 	gcc            : c-decl.c 
 	libstdc++-v3   : configure 
 	libstdc++-v3/include/bits: stl_deque.h locale_facets.h 
 	                           stl_iterator.h basic_ios.tcc 
 	                           sstream.tcc streambuf.tcc istream.tcc 
 	libstdc++-v3/include/std: std_istream.h std_streambuf.h 
 	libstdc++-v3/libsupc++: new 
 Added files:
 	gcc/testsuite/g++.dg/abi: layout1.C layout2.C mangle8.C rtti1.C 
 	gcc/testsuite/gcc.c-torture/execute: memset-3.c 
 	gcc/testsuite/gcc.dg: gnu89-init-2.c 
 Log message:
 	2002-07-24  Frank van der Linden  <>
 	PR optimization/7291
 	* config/i386/i386.c (ix86_expand_clrstr): Fix bzero alignment
 	problem on x86_64.
 	2002-05-16  Jason Merrill  <>
 	* config/mips/mips.c (mips_output_external): Don't do sdata
 	optimization for a variable with DECL_COMDAT set.
 	2002-01-03  Jakub Jelinek  <>
 	* c-decl.c (build_compound_literal): Set decl TREE_READONLY from TYPE.
 	* c-decl.c (build_compound_literal): Defer compound literal decls
 	until until file end to emit them only if they are actually used.
 	2002-07-17  Scott Snyder <>
 	PR c++/7320
 	* rtti.c (get_tinfo_decl): Set DECL_COMDAT.
 	2002-07-05  Nathan Sidwell  <>
 	Repair damage on weak-impared targets caused by my previous patch.
 	* cp-tree.h (import_export_tinfo): Add parameter.
 	* decl2.c (import_export_tinfo): Add parameter, post adjust
 	* rtti.c (emit_tinfo_decl): DECL_COMDAT is (nearly) always setup by
 	2002-06-30  Nathan Sidwell  <>
 	* cp-tree.h (CPTI_TINFO_DECL_TYPE): Replace with ...
 	(CPTI_TYPE_INFO_PTR_TYPE): ... this.
 	(tinfo_decl_type): Replace with ...
 	(type_info_ptr_type): ... this.
 	(import_export_tinfo): Declare.
 	(tinfo_decl_p): Rename to ...
 	(unemitted_tinfo_decl_p): ... this.
 	* decl2.c (import_export_decl): Break out tinfo handling into ...
 	(import_export_tinfo): ... here. New function.
 	(finish_file): Adjust.
 	* rtti.c (TINFO_REAL_NAME): New macro.
 	(init_rtti_processing): Create the tinfo types.
 	(get_tinfo_decl_dynamic): Use type_info_ptr_type, get_tinfo_ptr.
 	(get_tinfo_decl): Adjust.
 	(get_tinfo_ptr): New function.
 	(get_type_id): Use it.
 	(tinfo_base_init): Create vtable decl here, if it doesn't exist.
 	(ptr_initializer): Use get_tinfo_ptr.
 	(ptm_initializer): Likewise.
 	(synthesize_tinfo_var): Break into ...
 	(get_pseudo_ti_init): ... this. Just create the initializer.
 	(get_pseudo_ti_desc): .. and this.
 	(create_real_tinfo_var): Remove.
 	(create_pseudo_type_info): Don't create the vtable decl here.
 	(get_vmi_pseudo_type_info): Remove.
 	(create_tinfo_types): Adjust.
 	(tinfo_decl_p): Rename to ...
 	(unemitted_tinfo_decl_p): ... here. Adjust.
 	(emit_tinfo_decl): Adjust. Create the initializer.
 	2002-06-14  Jason Merrill  <>
 	C++ ABI changes.
 	* class.c (build_base_field): Set DECL_PACKED.
 	(layout_class_type): Don't use tail padding of PODs.
 	* mangle.c (write_unqualified_name): Fix template conversion op
 	2002-05-18  Jason Merrill  <>
 	PR c++/6611
 	* decl2.c (import_export_decl): If we clear
 	2002-05-14  Jason Merrill  <>
 	* rtti.c (get_tinfo_decl): Don't call comdat_linkage.
 	(synthesize_tinfo_var): Take the public decl.
 	(create_real_tinfo_var): Likewise.  Check DECL_COMDAT.
 	(emit_tinfo_decl): Adjust.  Call import_export_decl.
 	* decl2.c (import_export_decl): Simplify tinfo decl handling.
 	2002-07-24  Roger Sayle  <>
 	* gcc.c-torture/execute/memset-3.c: New testcase.
 	2002-06-14  Jason Merrill  <>
 	* g++.dg/abi/layout1.C: New test.
 	* g++.dg/abi/layout2.C: New test.
 	* g++.dg/abi/mangle8.C: New test.
 	2002-05-14  Jason Merrill  <>
 	* g++.dg/abi/rtti1.C: New test.
 	2002-01-03  Jakub Jelinek  <>
 	* gcc.dg/gnu89-init-2.c: New test.
 	2002-07-26  Phil Edwards  <>
 	* libsupc++/new (placement delete):  Remove unused paramater names.
 	2002-07-25  Benjamin Kosnik  <>
 	PR libstdc++/7216
 	* include/std/std_istream.h (basic_iostream): Add typedefs for
 	char_type, int_type, pos_type, off_type, and traits_type.
 	* testsuite/27_io/ (test01): Add typedef tests.
 	* testsuite/27_io/ Same.
 	* testsuite/27_io/ Same.
 	* testsuite/27_io/ Same.
 	* testsuite/27_io/ Replace content, move to...
 	* testsuite/27_io/
 	* testsuite/27_io/ Replace content, move to...
 	* testsuite/27_io/
 	* testsuite/27_io/ Replace content, move to...
 	* testsuite/27_io/
 	* testsuite/27_io/ New file.
 	* testsuite/27_io/ New file.
 	* testsuite/27_io/ New file.
 	* testsuite/27_io/ New file.
 	* testsuite/27_io/ New file.
 	* testsuite/27_io/ New file.
 	2002-07-25  Benjamin Kosnik  <>
 	PR libstdc++/7220
 	* include/bits/istream.tcc (istream::ignore): Don't extract on
 	* testsuite/27_io/ (test10): Add.
 	2002-07-24  Benjamin Kosnik  <>
 	PR libstdc++/7222
 	* src/ (locale::locale(const char*)): Use setlocale NULL.
 	* testsuite/22_locale/ (test02): New.
 	2002-07-24  Benjamin Kosnik  <>
 	PR libstdc++/7286
 	* libsupc++/new: Add placement delete.
 	* testsuite/18_support/ New.
 	2002-07-07  Paolo Carlini  <>
 	PR libstdc++/7186
 	* include/bits/stl_deque.h (_Deque_iterator::operator-):
 	Make non-member, as already happens for the comparison
 	operators in accord with DR179 (Ready).
 	* testsuite/23_containers/ Add test02.
 	2002-07-04  Benjamin Kosnik  <>
 	Jack Reeves  <>
 	* include/std/std_streambuf.h (basic_streambuf::_M_buf): Change to
 	size_t, from int_type.
 	(basic_streambuf::_M_buf_size_opt): Same.
 	(basic_streambuf::_S_pback_sizex): Same.
 	* include/bits/streambuf.tcc: Same.
 	* include/std/std_streambuf.h (basic_streambuf::snextc): Use
 	(basic_streambuf::uflow): Same.
 	* include/bits/sstream.tcc (basic_stringbuf::overflow): Use
 	* include/bits/basic_ios.tcc (basic_ios::init): Use _CharT().
 	* include/bits/streambuf.tcc (basic_streambuf::xsgetn): Use
 	(basic_streambuf::xsputn): Same.
 	(__copy_streambufs): Same.
 	2002-07-02  Paolo Carlini  <>
 	PR libstdc++/6642
 	* include/bits/stl_iterator.h
 	(__normal_iterator::operator-(const __normal_iterator&)):
 	Make non-member, as already happens for the comparison
 	operators in accord with DR179 (Ready).
 	* testsuite/24_iterators/ Add test from the PR.
 	2002-07-02  Benjamin Kosnik  <>
 	PR libstdc++/6410
 	* include/bits/locale_facets.h (moneypunct::moneypunct): Add const
 	char* name parameter.
 	* config/locale/gnu/ Use it.
 	* config/locale/generic/ Same.
 	* src/ (_Impl::_Impl(const char*, size_t)): Use it.
 	2002-07-01  Benjamin Kosnik  <>
 	* (libtool_VERSION): Bump to 5:0:0.
 	* configure: Regenerate.
 	2002-05-19  Paolo Carlini  <>
 	* testsuite/23_containers/ (test01):
 	Fix minor typo in last commit.
 	2002-05-18  Paolo Carlini  <>
 	PR libstdc++/6503
 	* include/bits/stl_deque.h (_Deque_iterator::operator==,
 	operator!=, operator<, operator>, operator>=, operator<=):
 	Make non-member functions, to allow comparing const and
 	non-const iterators in any order.
 	* testsuite/23_containers/ New testfile.