Denis Koroskin: > The code above should print: > state saved > state restored > > (not tested)
On Windows, dmd 2.048, this code: import std.c.stdio: puts; version (Windows) { alias int[16] jmp_buf; extern (C) extern { int setjmp(ref jmp_buf env); void longjmp(ref jmp_buf env, int value); } } struct State { int save() { return setjmp(buf); } void restore(int status) { assert(status != 0); longjmp(buf, status); } private jmp_buf buf; } void main() { State state; int result = state.save(); if (result == 0) { // first time here puts("state saved"); state.restore(1); } else { assert(result == 1); puts("state restored"); } } Gives an Access Violation after printing state saved. Bye, bearophile