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

--- Comment #3 from Steven Schveighoffer <schvei...@yahoo.com> ---
Jonathan, I think you misunderstand.

This compiles today, and uses the gc (using a user-supplied variable to prevent
folding into assert(0)):

void main(string[] args) @nogc
{
   assert(args.length > 100, "hi");
}

But this doesn't:

assert(args.length > 100, "hi".idup);

Note that the exception isn't constructed (or allocated), and the "hi".idup
isn't run unless something fails. This code is truly @nogc unless something
goes horribly wrong, in which case the program will exit anyway, who cares if
the gc is used?

Note, I'm not advocating that the expression 'new Error("msg")' be considered
@nogc. My point in saying that is this is effectively what an assert does, and
it's considered @nogc. All I'm saying is that asserts should be treated fully
as @nogc, not just the error construction part.

--

Reply via email to