Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact


Moderators: larsivi kris

Posted: 06/06/08 07:39:48

There is some mentioning in the docs that setjmp / longjmp does not work fully as expected and they have some problems with exceptions. Can any one elaborate? Does setjmp work at all (I am asking as I am about to start a project where setjmp / longjmp functionality is critical)?

Author Message

Posted: 06/06/08 17:38:03

I guess setjmp/longjmp are unsafe to use, but I have used them with success in the past, and they are also used as the fallback method for the Tango fibers. If they don't work with D and/or Tango I would assume it is a bug somewhere.

Posted: 06/11/08 00:27:53

setjmp/longjmp work (at least on non-Win32 platforms--the DigitalMars? impl. appears not to work with DMD) but the routines are not aware of scope objects, scope statements, etc, so none of this stuff will be called if you jump up the stack from your current position. So for most purposes use of setjmp/longjmp is discouraged in favor of throwing an exception, but there's nothing stopping you from using them if necessary. In fact, the Tango Fiber code used setjmp/longjmp as a failover option for a while, so I can guarantee that it works on linux, which is where I tested it at the time.