On 6/22/20 10:36 AM, Per Nordlöw wrote:
On Monday, 22 June 2020 at 14:10:15 UTC, Mike Parker wrote:
https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md

The spec says:

"
The only place a refcounted Throwable is ever created is when the following statement is in the user code:

throw new E(string);
"

What other typical throw cases will _not_ be allocated on the GC?

My understanding is none.

So for example:

auto ex = new Exception(string); // heap allocated
throw ex;

It entirely depends on you immediately throwing the exception because otherwise, you may have stored a pointer elsewhere. Because classes (exceptions) cannot be truly refcounted on copy, you need a very controlled environment to ensure the ref-counting works.

-Steve

Reply via email to