@nogc and Exceptions

Adam D Ruppe destructionator at gmail.com
Thu Sep 29 12:31:52 UTC 2022


On Thursday, 29 September 2022 at 12:12:34 UTC, Quirin Schroll 
wrote:
> * Ignore the issue at a language level and just lie (code 
> below): Make an `Exception` allocating function and cast it to 
> `@nogc`. I do not know if that is UB.

It actually already does this. Even if you malloc an exception 
(which you can), the exception's ctor will call the trace info 
hook, which GC allocates yet lies about it.


i've written a few random things about exceptions over the last 
year:
http://dpldocs.info/this-week-in-d/Blog.Posted_2021_08_16.html
http://dpldocs.info/this-week-in-d/Blog.Posted_2021_08_23.html
http://dpldocs.info/this-week-in-d/Blog.Posted_2022_06_27.html
http://dpldocs.info/this-week-in-d/Blog.Posted_2022_08_01.html#exception-template-concept

including some talk about just lying. nogc is kinda silly to 
begin with and if you want both nogc and nothrow you can... write 
nogc nothrow.


More information about the Digitalmars-d mailing list