[Issue 22986] Phobos cannot be compiled with dip1008

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 4 12:22:40 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22986

Adam D. Ruppe <destructionator at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |destructionator at gmail.com

--- Comment #1 from Adam D. Ruppe <destructionator at gmail.com> ---
@nogc is too restrictive and all these hoops we jump through to enable it is
reducing the overall quality of D. Would be better if it focused on avoiding
leaks outside a function than avoiding all allocations, then as long as you
pair your news with deletes, you'd be ok.

Anyway, cloning an exception is not easy, you're liable to have random problems
with that (remember exceptions are not necessarily allocated with `new` in any
case... so if it was malloc'd and you didn't free it, you're in some trouble,
but this perhaps rare enough to ignore).

I guess you could check the RTTI and bit copy back out the GC upon escaping,
and just hope it doesn't have any references to itself. A virtual clone
function that can be overridden but whose default digs typeinfo out to work in
the general case perhaps would let you escape.

Might be worth experimenting with that.

--


More information about the Digitalmars-d-bugs mailing list