I can has @nogc and throw Exceptions?

Jonathan Marler via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Feb 13 11:17:15 PST 2015


On Friday, 13 February 2015 at 19:13:02 UTC, Steven Schveighoffer 
wrote:
> You need to actually allocate the memory on the heap. Your data 
> lives on the stack frame of main, which goes away as soon as 
> main exits, and your exception is caught outside main.
>
> -Steve

Yes I am aware of this.  That doesn't mean you have to allocate 
on the GC heap.  You can

1. Make sure the exception is caught before the function that 
allocated the memory for it on the stack (not the safest thing to 
do but works)
2. Allocate the memory on the NON-GC heap
3. Allocate the memory to a global



More information about the Digitalmars-d-learn mailing list