[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Using "typename std::iterator" causes segfault



>Submitter-Id:	net
>Originator:	Roger Leigh
>Organization:	Debian Project
>Confidential:	no
>Synopsis:	Using "typedef typename std::iterator difference_type" causes a segfault.
>Severity:	non-critical
>Priority:	low
>Category:	c++
>Class:		ice-on-illegal-code
>Release:	3.3.3 20031229 (prerelease) (Debian) (Debian testing/unstable)
>Environment:
System: Linux wrynose 2.6.1 #3 Tue Jan 20 23:27:03 GMT 2004 i686 GNU/Linux
Architecture: i686

	
host: i486-pc-linux-gnu
build: i486-pc-linux-gnu
target: i486-pc-linux-gnu
configured with: ../src/configure -v --enable-languages=c,c++,java,f77,pascal,objc,ada,treelang --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-include-dir=/usr/include/c++/3.3 --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --enable-debug --enable-java-gc=boehm --enable-java-awt=xlib --enable-objc-gc i486-linux
>Description:
$ g++ -o test test.cc
test.cc:24: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
>How-To-Repeat:
    1	#include <iterator>
    2	
    3	template<typename T>
    4	class myclass
    5	{
    6	private:
    7	  T m_value;
    8	public:
    9	  myclass(T& value): m_value(value) {}
   10	
   11	  class myiter : public std::iterator<std::random_access_iterator_tag, T, std::size_t>
   12	  {
   13	  public:
   14	    typedef std::size_t size_type;
   15	    typedef typename std::iterator difference_type;
   16	
   17	  private:
   18	    size_type m_pos;
   19	
   20	    myiter(size_type pos): m_pos(pos) {}
   21	
   22	  public:
   23	    myiter operator + (difference_type incr)
   24	    {
   25	      size_type pos = m_pos;
   26	      if (pos + incr < m_result->size())
   27		pos += incr;
   28	      else
   29		pos = m_result->size();
   30	      return myiter(*m_result, pos);
   31	    }
   32	  };
   33	};
   34	
   35	int main()
   36	{
   37	  myclass<int> i;
   38	  return 0;
   39	}
>Fix:
None, sorry.



Reply to: