From cb40c9f8baf67abd454c4091cf18075ba6d2c8ae Mon Sep 17 00:00:00 2001 From: asfernandes Date: Sat, 13 Jun 2009 16:36:10 +0000 Subject: [PATCH] Apply Alex/Bill/Jerry/me patch re. portability in redefinition of operator new --- src/common/classes/alloc.h | 15 ++++++++------- src/include/fb_exception.h | 5 +++-- src/include/gen/autoconfig_msvc.h | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/common/classes/alloc.h b/src/common/classes/alloc.h index 1f96c14ca4..74ed397a53 100644 --- a/src/common/classes/alloc.h +++ b/src/common/classes/alloc.h @@ -49,13 +49,14 @@ stdlib.h (EKU) */ #endif -#include - -#if defined (_MSC_VER) || defined (__SUNPRO_CC) || defined(__xlC__) -#define THROW_BAD_ALLOC -#else -#define THROW_BAD_ALLOC throw (Firebird::BadAlloc) -#endif +// MSVC does not support exception specification, so it's unknown if that will be correct or not +// from its POV. For now, use it and disable the C4290 warning. +// +//#if defined (_MSC_VER) +//#define THROW_BAD_ALLOC +//#else +#define THROW_BAD_ALLOC throw (std::bad_alloc) +//#endif #ifdef USE_VALGRIND diff --git a/src/include/fb_exception.h b/src/include/fb_exception.h index 57cc9cefc5..46a082a3de 100644 --- a/src/include/fb_exception.h +++ b/src/include/fb_exception.h @@ -32,6 +32,7 @@ #include #include +#include #include "fb_types.h" #include "../common/StatusArg.h" @@ -112,13 +113,13 @@ public: }; // Used in MemoryPool -class BadAlloc : public Exception +class BadAlloc : public std::bad_alloc, public Exception { public: virtual ISC_STATUS stuff_exception(ISC_STATUS* const status_vector, StringsBuffer* sb = NULL) const throw(); virtual const char* what() const throw() { return "Firebird::BadAlloc"; } static void raise(); - BadAlloc() throw() : Exception() { } + BadAlloc() throw() : std::bad_alloc(), Exception() { } }; // Main exception class in firebird diff --git a/src/include/gen/autoconfig_msvc.h b/src/include/gen/autoconfig_msvc.h index fbb1e76b1b..eb9926cf7c 100644 --- a/src/include/gen/autoconfig_msvc.h +++ b/src/include/gen/autoconfig_msvc.h @@ -41,6 +41,7 @@ #pragma warning(disable:4214) // nonstandard extension used : bit field types other than int #pragma warning(disable:4244) // conversion from '.......' to '......', possible loss of data #pragma warning(disable:4245) // conversion from '.......' to '......', signed/unsigned mismatch +#pragma warning(disable:4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) #pragma warning(disable:4291) // no matching operator delete found; memory will not be freed if initialization throws an exception #pragma warning(disable:4309) // truncation of constant value #pragma warning(disable:4310) // cast truncates constant value