On Tuesday, 21 November 2017 at 18:56:03 UTC, Adam D. Ruppe wrote:
On Tuesday, 21 November 2017 at 18:49:40 UTC, David Zhang wrote:
        assert(false, chars[0..str.length]);
}

What am I missing here?

You're escaping a reference to a local variable there. chars[] is a pointer to the stack, which is promptly smashed when the assert error starts working up the call chain, so by the time it actually prints, you have undefined behavior.

So I'd have to allocate the buffer on the heap then...
Is there any way to do this without allocating to the stack?

Reply via email to