c++/4265 is not a gcc bug

Philip Martin philip_martin@ntlworld.com
Sat Sep 8 17:28:00 GMT 2001


http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4265&database=gcc

Ugh! Your code boils down to something like

   #include <map>
   using namespace std;

   class X { };
   class Y { };
   typedef map<X, Y> M;

   template<template<typename X, typename R, typename P> class iterator, class T>
   iterator<T, T&, T*>& map_iterator_const_cast (iterator<T, T const&, T const*> const&)
   {
      static iterator<T, T&, T*> foo;
      return foo;
   }

   int main()
   {
      M::const_iterator const& i(0);
      map_iterator_const_cast<M::iterator&>( i ); // this line is wrong
   }

To get that line to compile you need to specify a template, not a
type. Something like:

     map_iterator_const_cast<_Rb_tree_iterator>( i );

where _Rb_tree_iterator is the template type used for the std::map
iterator, buried inside stl_tree.h.

This is not a gcc bug.

Philip



More information about the Gcc-bugs mailing list