Article View: gnu.g++.help
Article #858Re: setjmp/longjmp in C++
From: Mike Rubenstein
Date: Sun, 17 Dec 1995 17:17
Date: Sun, 17 Dec 1995 17:17
29 lines
1456 bytes
1456 bytes
alexr@msil.sps.mot.COM (Alex Rezinsky) wrote: |> |> Hi all, |> |>Can I use setjmp/longjmp routines in C++ environment (g++ compiler)? |>Do they save/restore C++ environment correctly? |>Does longjmp call default destructors? In theory you can use setjmp/longjmp, in C++, but they are very restricted. From the September draft 18.7: The function signature longjmp(jmp_buf jbuf, int val) has more restricted behavior in this International Standard. If any automatic objects would be destroyed by a thrown exception transferring control to another (destination) point in the program, then a call to longjmp(jbuf, val) at the throw point that transfers control to the same (destination) point has undefined behavior. In practice, this is so restrictive that I would say that these macros are not usable in C++. Use exceptions instead. I expect that most compilers will not destroy auto objects when longjmp() is called unless they actually implement setjmp/longjmp with exceptions. Michael M Rubenstein
Technical Details
Message-ID:
<30d44f0c.77032192@nntp.ix.netcom.com>Path:
arc1-ca.pugleaf.net!ix.netcom.com!netnewsReferences:
<9512171357.AA03464@msil.sps.mot.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ix.netcom.com!netnews From: miker3@ix.netcom.com (Mike Rubenstein) Newsgroups: gnu.g++.help,comp.lang.c++ Subject: Re: setjmp/longjmp in C++ Date: Sun, 17 Dec 1995 17:17:45 GMT Organization: Netcom Message-ID: <30d44f0c.77032192@nntp.ix.netcom.com> References: <9512171357.AA03464@msil.sps.mot.com> NNTP-Posting-Host: ix-dc6-03.ix.netcom.com X-Newsreader: Forte Agent .99c/16.141