From 5ecac228c6dbdb1e1b30a3eda3427e14f849f16e Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Tue, 25 May 2004 17:27:23 +0000 Subject: [PATCH] fixed large new size that throws an exception --- src/libCom/test/epicsExceptionTest.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libCom/test/epicsExceptionTest.cpp b/src/libCom/test/epicsExceptionTest.cpp index ee2dff482..2b4cbd1f9 100644 --- a/src/libCom/test/epicsExceptionTest.cpp +++ b/src/libCom/test/epicsExceptionTest.cpp @@ -30,6 +30,17 @@ const nothrow_t nothrow ; } #endif +// some interesting bugs found in the MS implementation of new +#if defined ( _MSC_VER ) +# if _MSC_VER > 1310 /* this gets fixed some release after visual studio 7 we hope */ + static const size_t unsuccessfulNewSize = numeric_limits::max(); +# else + static const size_t unsuccessfulNewSize = numeric_limits::max()-100; +# endif +#else + static const size_t unsuccessfulNewSize = numeric_limits::max(); +#endif + class myThread : public epicsThreadRunable { public: myThread (); @@ -44,7 +55,7 @@ static void epicsExceptionTestPrivate () { int excep = false; try { - new char [numeric_limits::max (size_t)]; + new char [unsuccessfulNewSize]; assert ( 0 ); } catch ( const bad_alloc & ) { @@ -54,7 +65,8 @@ static void epicsExceptionTestPrivate () assert ( 0 ); } try { - char * p = new ( nothrow ) char [LONG_MAX]; + char * p = new ( nothrow ) + char [unsuccessfulNewSize]; assert ( p == 0); } catch( ... ) {