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

Gabriel Dos Reis gdr@integrable-solutions.net
Wed Dec 4 10:26:00 GMT 2002


nbecker@hns.com (Neal D. Becker) writes:

[...]

| 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.

If step 4 is OK, then step 5 ought to be OK: the input iterator is of
pointer type. 

As an aside,  this is a case where I really do prefer class
template-based compile-time dispatcher over overloading.

-- Gaby



More information about the Gcc mailing list