Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.2.0, 4.2.1
-
None
-
All
-
Patch Available
-
Regression
-
Compiler Error
Description
The following test fails to compile:
#include <memory> #include <iterator> struct InputIterator: std::iterator<std::input_iterator_tag, char> { const char *p_; InputIterator (const char *p): p_ (p) { } InputIterator (const InputIterator &rhs): p_ (rhs.p_) { } InputIterator& operator= (const InputIterator &rhs) { p_ = rhs.p_; return *this; } char operator* () const { return *p_; } InputIterator& operator++ () { return ++p_, *this; } InputIterator operator++ (int) { return ++p_, InputIterator (p_ - 1); } bool operator== (const InputIterator &rhs) const { return p_ == rhs.p_; } bool operator!= (const InputIterator &rhs) const { return p_ != rhs.p_; } }; int main () { char src [5] = "abcd"; char dst [5]; std::uninitialized_copy (InputIterator (src), InputIterator (src + 5), dst); return 0; }
D:\_Libs\stdcxx-4.2.2\include\rw\_specialized.h(168) : error C2665: '__rw::__rw_construct' : none of the 2 overloads can convert parameter 2 from type 'char' D:\_Libs\stdcxx-4.2.2\include\rw\_specialized.h(88): could be 'void __rw::__rw_construct<char,char>(_TypeT *,_TypeU &)' with [ _TypeT=char, _TypeU=char ] D:\_Libs\stdcxx-4.2.2\include\rw\_specialized.h(96): or 'void __rw::__rw_construct<char,char>(volatile _TypeT *,_TypeU &)' with [ _TypeT=char, _TypeU=char ] while trying to match the argument list '(char *, char)' test.cpp(29) : see reference to function template instantiation '_ForwardIterator std::uninitialized_copy<InputIterator,char*>(_InputIterator,_InputIterator,_ForwardIterator)' being compiled with [ _ForwardIterator=char *, _InputIterator=InputIterator ]
The fix:
Index: include/rw/_specialized.h =================================================================== --- include/rw/_specialized.h (revision 671890) +++ include/rw/_specialized.h (working copy) @@ -85,7 +85,7 @@ template <class _TypeT, class _TypeU> inline void -__rw_construct (_TypeT* __p, _TypeU& __val) +__rw_construct (_TypeT* __p, const _TypeU& __val) { ::new (_RWSTD_STATIC_CAST (void*, __p)) _TypeT (__val); } @@ -93,7 +93,7 @@ template <class _TypeT, class _TypeU> inline void -__rw_construct (volatile _TypeT* __p, _TypeU& __val) +__rw_construct (volatile _TypeT* __p, const _TypeU& __val) { // remove volatile before invoking operator new __rw_construct (_RWSTD_CONST_CAST (_TypeT*, __p), __val); @@ -103,7 +103,7 @@ template <class _TypeT, class _TypeU> inline void -__rw_construct_impl (_TypeT* __p, _TypeU& __val) +__rw_construct_impl (_TypeT* __p, const _TypeU& __val) { ::new (_RWSTD_STATIC_CAST (void*, __p)) _TypeT (__val); } @@ -111,7 +111,7 @@ template <class _TypeT, class _TypeU> inline void -__rw_construct (volatile _TypeT* __p, _TypeU& __val) +__rw_construct (volatile _TypeT* __p, const _TypeU& __val) { // remove volatile before invoking operator new __rw_construct_impl (_RWSTD_CONST_CAST (_TypeT*, __p), __val);
Attachments
Issue Links
- depends upon
-
STDCXX-1005 [HP aCC 3.73] ICE on +DD64 and partial specialization
- Open
- is related to
-
STDCXX-390 [HP aCC 3.73] error on std::uninitialized_copy<volatile T*, U>()
- Closed