On Sat, Apr 07, 2007 at 04:01:57PM -0500, Gabriel Dos Reis wrote:
> [EMAIL PROTECTED] (Ross Ridge) writes:
> 
> | Joe Buck writes:
> | >If a check were to be implemented, the right thing to do would be to throw
> | >bad_alloc (for the default new) or return 0 (for the nothrow new).
> | 
> | Ross Ridge writes:
> | >What do you do if the user has defined his own operator new that does
> | >something else?
> | 
> | Gabriel Dos Reis writes:
> | >More precisely?
> | 
> | Well, for example, like all other things that a new_handler can do,
> | like throwing an exception derived from bad_alloc or calling exit().
> | In addition, any number of side effects are possible, like printing
> | error messages or setting flags.
> 
> I believe you're confused about the semantics.  
> The issue here is that the *size of object* requested can be
> represented.  That is independent of whether the machine has enough
> memory or not.  So, new_handler is a red herring.

The user's new function will be passed a size that has been converted into
bytes.  If gcc's implementation does multiply-with-saturation instead of
straight multiply to get this size, user-defined new operators will work
as expected.

Reply via email to