Commit dafa8871 by Paolo Carlini Committed by Paolo Carlini

std_memory.h (__get_temporary_buffer): Don't use INT_MAX...

2004-10-09  Paolo Carlini  <pcarlini@suse.de>

	* include/std/std_memory.h (__get_temporary_buffer): Don't use
	INT_MAX, prefer numeric_limits<ptrdiff_t>::max(), ok on 64-bit
	platforms too.
	* testsuite/20_util/memory/auto_ptr/assign_neg.cc: Adjust dg-error
	line numbers.

From-SVN: r88814
parent c3e7f184
2004-10-09 Paolo Carlini <pcarlini@suse.de>
* include/std/std_memory.h (__get_temporary_buffer): Don't use
INT_MAX, prefer numeric_limits<ptrdiff_t>::max(), ok on 64-bit
platforms too.
* testsuite/20_util/memory/auto_ptr/assign_neg.cc: Adjust dg-error
line numbers.
2004-10-08 Benjamin Kosnik <bkoz@redhat.com> 2004-10-08 Benjamin Kosnik <bkoz@redhat.com>
* acconfig.h: Add _GLIBCXX_USE___CXA_ATEXIT. * acconfig.h: Add _GLIBCXX_USE___CXA_ATEXIT.
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <bits/stl_uninitialized.h> #include <bits/stl_uninitialized.h>
#include <bits/stl_raw_storage_iter.h> #include <bits/stl_raw_storage_iter.h>
#include <debug/debug.h> #include <debug/debug.h>
#include <limits>
namespace std namespace std
{ {
...@@ -73,8 +74,9 @@ namespace std ...@@ -73,8 +74,9 @@ namespace std
pair<_Tp*, ptrdiff_t> pair<_Tp*, ptrdiff_t>
__get_temporary_buffer(ptrdiff_t __len, _Tp*) __get_temporary_buffer(ptrdiff_t __len, _Tp*)
{ {
if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) const ptrdiff_t __max = numeric_limits<ptrdiff_t>::max() / sizeof(_Tp);
__len = INT_MAX / sizeof(_Tp); if (__len > __max)
__len = __max;
while (__len > 0) while (__len > 0)
{ {
...@@ -105,7 +107,7 @@ namespace std ...@@ -105,7 +107,7 @@ namespace std
* Provides the nothrow exception guarantee. * Provides the nothrow exception guarantee.
*/ */
template<typename _Tp> template<typename _Tp>
inline pair<_Tp*,ptrdiff_t> inline pair<_Tp*, ptrdiff_t>
get_temporary_buffer(ptrdiff_t __len) get_temporary_buffer(ptrdiff_t __len)
{ return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); } { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); }
......
...@@ -46,5 +46,5 @@ main() ...@@ -46,5 +46,5 @@ main()
test01(); test01();
return 0; return 0;
} }
// { dg-error "candidates" "" { target *-*-* } 222 } // { dg-error "candidates" "" { target *-*-* } 224 }
// { dg-error "std::auto_ptr" "" { target *-*-* } 352 } // { dg-error "std::auto_ptr" "" { target *-*-* } 354 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment