From 0c7a5c66fbdd63816794dc1f23b41ec98d3b11af Mon Sep 17 00:00:00 2001 From: paolo Date: Sat, 9 Oct 2004 08:23:02 +0000 Subject: 2004-10-09 Paolo Carlini * include/std/std_memory.h (__get_temporary_buffer): Don't use INT_MAX, prefer numeric_limits::max(), ok on 64-bit platforms too. * testsuite/20_util/memory/auto_ptr/assign_neg.cc: Adjust dg-error line numbers. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88814 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/include/std/std_memory.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'libstdc++-v3/include/std/std_memory.h') diff --git a/libstdc++-v3/include/std/std_memory.h b/libstdc++-v3/include/std/std_memory.h index 4e6641ef673..1d278e6cb86 100644 --- a/libstdc++-v3/include/std/std_memory.h +++ b/libstdc++-v3/include/std/std_memory.h @@ -58,6 +58,7 @@ #include #include #include +#include namespace std { @@ -73,8 +74,9 @@ namespace std pair<_Tp*, ptrdiff_t> __get_temporary_buffer(ptrdiff_t __len, _Tp*) { - if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) - __len = INT_MAX / sizeof(_Tp); + const ptrdiff_t __max = numeric_limits::max() / sizeof(_Tp); + if (__len > __max) + __len = __max; while (__len > 0) { @@ -105,7 +107,7 @@ namespace std * Provides the nothrow exception guarantee. */ template - inline pair<_Tp*,ptrdiff_t> + inline pair<_Tp*, ptrdiff_t> get_temporary_buffer(ptrdiff_t __len) { return std::__get_temporary_buffer(__len, static_cast<_Tp*>(0)); } -- cgit v1.2.3