setAssertHandler (druntime) segfaults

Lutger lutger.blijdestijn at gmail.com
Fri Jul 24 13:37:06 PDT 2009


There is a function setAssertHandler in druntime, but when I try to use it 
it segfaults. I'm not sure how it should be used, this is a complete example 
of what I try to do:

import std.stdio;
import core.exception;

void handleAssertion(string file, size_t line, string msg = null)
{
    writefln("assert in %s at line %s", file, line);
};

static this()
{
    setAssertHandler( &handleAssertion  );
}

unittest { assert(false); }

void main() {}


output:
assert in test at line 16
Segmentation fault

This is with dmd 2.031 on linux. Is this a bug, am I doing something wrong? 




More information about the Digitalmars-d-learn mailing list