Allocation failures

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 17 08:44:35 PST 2016


On Wed, 17 Feb 2016 02:24:51 +0000, cym13 wrote:

> On Wednesday, 17 February 2016 at 02:23:34 UTC, cym13 wrote:
>> Such errors are static errors, they aren't allocated on the stack, a
>> 128 bytes buffer is shared accross threads to keep them.
> 
> Sorry, of course I meant they *are* allocated on the stack.

In the context of exceptions, you can't allocate them on the stack at the 
point at which you throw them. As soon as you throw them, the stack frame 
is invalidated (to run destructors for stack-scoped items, possibly other 
things), so your exception object is at least moderately likely to be 
corrupted.

You *could* allocate them on the stack in, say, main(), but then you'd 
have to pass a reference to them down the stack somehow. Kind of awkward.


More information about the Digitalmars-d mailing list