From: Paolo Carlini Date: Sat, 9 Oct 2004 08:23:02 +0000 (+0000) Subject: std_memory.h (__get_temporary_buffer): Don't use INT_MAX... X-Git-Tag: releases/gcc-4.0.0~4175 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=dafa8871d1c8c0375763a36a63cc31fee6c0af1c;p=thirdparty%2Fgcc.git std_memory.h (__get_temporary_buffer): Don't use INT_MAX... 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. From-SVN: r88814 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 615d83f51d7a..19be8461c17a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +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. + 2004-10-08 Benjamin Kosnik * acconfig.h: Add _GLIBCXX_USE___CXA_ATEXIT. diff --git a/libstdc++-v3/include/std/std_memory.h b/libstdc++-v3/include/std/std_memory.h index 4e6641ef6739..1d278e6cb868 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)); } diff --git a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc index 8899c9893ace..fc4ba5b90fd3 100644 --- a/libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc +++ b/libstdc++-v3/testsuite/20_util/memory/auto_ptr/assign_neg.cc @@ -46,5 +46,5 @@ main() test01(); return 0; } -// { dg-error "candidates" "" { target *-*-* } 222 } -// { dg-error "std::auto_ptr" "" { target *-*-* } 352 } +// { dg-error "candidates" "" { target *-*-* } 224 } +// { dg-error "std::auto_ptr" "" { target *-*-* } 354 }