Hi,

import std.stdio, std.exception;

void main(){
  class C{
    void foo(){ writeln(123); }
  }

  C c;
  try{
    writeln(1);
    c.foo;        // access violation here
    writeln(2);
  }catch(Throwable t){
    writeln("exception");
  }
  writeln(3);
}

When I run this code (using LDC2 64bit Windows), it silently crashes where the access violation happens and returns an %ERRORLEVEL% value of -1073741795 (-0x3FFFFFE3).

On the Online DLang Editor I get some more information:
Error: /tmp/onlineapp-cf8e338-8b2478 failed with status: -2
Error: message: Segmentation fault (core dumped)
Error: program received signal 2 (Interrupt)

This is better, but is there a trick to turn these system errors to an exception, so I would be able to get the location where it crashed in my source code?

The best I've found is this trick for Linux: https://forum.dlang.org/post/atxyappczlyvqyalv...@forum.dlang.org

That error message would be so usefull, but is there a way to do it on windows?

Reply via email to