serious bug in libstdc++-3.2 std::copy?

Neal D. Becker nbecker@hns.com
Wed Dec 4 08:26:00 GMT 2002


I am copying from a custom container (RingBuffer) to a vector.  The
RingBuffer has a special iterator.  I use std::copy.  I get a
segfault.  GDB tells me:

1.
  template<typename _InputIter, typename _OutputIter>
    inline _OutputIter
    copy(_InputIter __first, _InputIter __last, _OutputIter __result)

OK so far.

2. template<typename _InputIter, typename _OutputIter>
    inline _OutputIter
    __copy_ni1(_InputIter __first, _InputIter __last,
	       _OutputIter __result, __false_type)

OK, input is not normal.

3. inline _OutputIter
    __copy_ni2(_InputIter __first, _InputIter __last,
	       _OutputIter __result, __true_type)

OK, output is normal

4. template<typename _Tp>
    inline _Tp*
    __copy_aux2(_Tp* __first, _Tp* __last,
		_Tp* __result, __true_type)

OK, type has trivial assign (in this case it is int)

5. template<typename _Tp>
    inline _Tp*
    __copy_trivial(const _Tp* __first, const _Tp* __last, _Tp*
    __result)

Wrong!  This calls memmove.  But the input iterator doesn't have
pointer-type semantics.

Am I misunderstanding something, or is there a serious bug here?



More information about the Gcc mailing list