This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: operator new catch parameter type gcc 4.3.2
- From: Ian Lance Taylor <iant at google dot com>
- To: "Jan M" <jan_m at jerseymail dot co dot uk>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: Thu, 11 Nov 2010 09:04:16 -0800
- Subject: Re: operator new catch parameter type gcc 4.3.2
- References: <8C07A35F09A44C0CA435094DABF35043@intel>
"Jan M" <jan_m@jerseymail.co.uk> writes:
> What catch() parameter type should be used with operator new try/catch
> block?
>
> gcc 4.3.2 objects to catch(std::bad_alloc &) but accepts catch(...)
> which I am told is not supported (and certainly
> did not catch any exception I threw).
>
> If I #include <c++/4.2.3/backward/new.h> catch(std::bad_alloc &) is
> accepted but presumably implements an old new
> handler.
>
> I cannot make operator new fail to check this (even allocating a
> terabyte succeeds) .
>
> Does catch(...) work with the standard operator new in 4.3.2?
We would have an easier time answering your question if you showed us a
small complete piece of code. I don't understand what fails or why.
If operator new fails, it will throw std::bad_alloc.
Ian