longjmp [still] crashes on windows?

tipdbmp email at example.com
Tue Oct 16 20:13:12 UTC 2018


An old thread about the same problem: 
https://forum.dlang.org/thread/mmxwhdypncaeikknlpyq@forum.dlang.org

struct jmp_buf {
     byte[256] data;
}

jmp_buf my_jmp_buf;

extern(C) {
     int setjmp(ref jmp_buf env);
     void longjmp(ref jmp_buf env, int);
}

void
second() {
     writefln("second");
     // calling 'longjmp' results in a crash with '-m64'
     // it works with '-m32mscoff'
     longjmp(my_jmp_buf, 1);
}

void
first() {
     second();
     writefln("first");
}

void
main() {
     if (setjmp(my_jmp_buf)) {
         writefln("we longjmp-ed to here");
     }
     else {
         first();
     }
}

I also want to use '-betterC' (exceptions won't work).



More information about the Digitalmars-d-learn mailing list