D语言中无法捕获函数指针为null的异常

import std.stdio;
int main(string[] argv)
{
    try
    {
        auto f = delegate(){};
        f = null;
        f();
    }
    catch(Throwable e)
    {
        writeln(e.msg);
    }
    readln();
    return 0;
}

        在调试中,函数或委托的指针为null时,异常无法捕获,直接退出。只有在程序运行时才能捕获得到。

       以上问题需要打开VS异常设置:

image

原文地址:https://www.cnblogs.com/wanhongnan/p/5731342.html