Exceptions in @nogc code

Eugene Wissner via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 1 12:52:14 PDT 2017


On Saturday, 1 April 2017 at 18:56:56 UTC, Guillaume Piolat wrote:
> (currently using @nogc exceptions with malloc+emplace and 
> destroy+free)
>
> OK. The important bit imho is that exception don't become 
> special class objects.
> ie. "scope new" is not specific to exceptions.
> The other @nogc blocker is .destroy

If I understand correctly exceptions are anyway special class 
objects. A scope Exception wouldn't be allocated in the current 
scope, but elsewhere, so it can be catched outside the current 
stack frame. The same as Errors are special class objects, they 
can be thrown regardless nothrow and @nogc, because these aren't 
recoverable errors.


More information about the Digitalmars-d mailing list