<div dir="ltr"><div>update: with @nogc @trusted pure this becomes even uglier:</div><div><br></div><div><br></div><div>@nogc @trusted pure</div><div>void test(int a){</div><div>  if(!(a==3)){</div><div>    debug{</div><div>    char[100]buf; //TODO:make sure big enough</div><div>    // would like to use 'auto s=sformat(buf, "a = %s", a);' but not nogc: <a href="https://issues.dlang.org/show_bug.cgi?id=13055">https://issues.dlang.org/show_bug.cgi?id=13055</a> </div><div>    auto m=snprintf(buf.ptr, buf.length, "a = %d", a);</div><div>    assert(m<buf.length && m>0);</div><div>    assert(0, buf[0..m]);</div><div>    }</div><div>    else{</div><div>      assert(0);</div><div>    }</div><div>  }</div><div>}</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 9, 2016 at 11:54 PM, Timothee Cour <span dir="ltr"><<a href="mailto:thelastmammoth@gmail.com" target="_blank">thelastmammoth@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Is there a better way than the example below to have an informative (ie formatted with runtime values) error message inside a nogc function?</div><div><br></div><div>@nogc</div><div>void test(int a){</div><div>  char[100]buf; //TODO:make sure big enough</div><div>  //auto s=sformat(buf, "a = %s", a);/// not nogc even though it accepts a buf</div><div>  auto m=snprintf(buf.ptr, buf.length, "a = %d", a);</div><div>  assert(m<buf.length && m>0);</div><div>  assert(a==3, buf[0..m]);</div><div>}</div><div><br></div></div>
</blockquote></div><br></div>