Should debug{} allow GC?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 11 03:19:56 PDT 2016


On Sunday, September 11, 2016 17:46:09 Manu via Digitalmars-d wrote:
> I'm having a lot of trouble debugging @nogc functions. I have a number
> of debug functions that use GC, but I can't call them from @nogc
> code... should debug{} allow @nogc calls, the same as impure calls?

Probably. There might be some problems if a program relies on stuff being
@nogc, and it's compiled with -debug, and it uses code that uses the GC in
debug statements, but it _is_ -debug, and in most cases, I would expect
debug statements to be temporary rather than left in a library that was
distributed (which is the sort of place that it might actually become a
problem). Certainly, on the whole, I think that the reasons for disallowing
use of the GC in debug statements could just as easily be applied to using
impure code in debug statements, and we allow that precisely because it's so
useful for debugging.

- Jonathan M Davis



More information about the Digitalmars-d mailing list