www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - formatted assert error messages inside nogc functions

Is there a better way than the example below to have an informative (ie
formatted with runtime values) error message inside a nogc function?

 nogc
void test(int a){
  char[100]buf; //TODO:make sure big enough
  //auto s=sformat(buf, "a = %s", a);/// not nogc even though it accepts a
buf
  auto m=snprintf(buf.ptr, buf.length, "a = %d", a);
  assert(m<buf.length && m>0);
  assert(a==3, buf[0..m]);
}
Jan 09