www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - When is exception throwing nogc with -dip1008?

reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
Under what circumstances is exception throwing currently ` nogc` 
if the dmd flag `-dip1008` is used?

For instance in code such as:

void main()  nogc
{
     throw new Exception("I'm  nogc now");
}

Are all exceptions forced to be statically allocated when 
-dip1008 is used or can exception throwing be ` nogc` only when 
certain conditions hold?

I can't find any docs on DIP-1008. The link

https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md

given in the release notes here

Ref: https://dlang.org/changelog/2.079.0.html#dip1008

is broken.
Jun 22 2020
next sibling parent Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
On Monday, 22 June 2020 at 13:59:22 UTC, Per Nordlöw wrote:
 I can't find any docs on DIP-1008. The link

 https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md

 is broken.
Found the postponed spec here: https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md
Jun 22 2020
prev sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Monday, 22 June 2020 at 13:59:22 UTC, Per Nordlöw wrote:

 I can't find any docs on DIP-1008. The link

 https://github.com/dlang/DIPs/blob/master/DIPs/DIP1008.md

 given in the release notes here

 Ref: https://dlang.org/changelog/2.079.0.html#dip1008

 is broken.
https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1008.md
Jun 22 2020
parent reply Per =?UTF-8?B?Tm9yZGzDtnc=?= <per.nordlow gmail.com> writes:
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?
Jun 22 2020
parent Steven Schveighoffer <schveiguy gmail.com> writes:
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
Jun 22 2020