From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,2ed1109624fc8c90 X-Google-Attributes: gidfee84,public From: Jeff Sullivan Subject: Re: 4.0D/4.0E DEC C optimization bug Date: 1999/04/13 Message-ID: <3713880D.ECF3B246@zk3.dec.com>#1/1 X-Deja-AN: 465972538 Content-Transfer-Encoding: 7bit References: <5tXNlnALx$2QR$1@joerch.org> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Compaq Computer Corporation Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 The following answer comes from one of our ANSI experts. My take on this is that it's a bug in that the compiler does not know that sigsetjmp behaves like setjmp. The Single UNIX Spec has the same words about sigsetjmp and the values of non-volatile locals as the C89 and C9X specs have for setjmp and non-volatile locals. If this example is coded with setjmp/longjmp instead of the sig-prefixed versions, then we generate different code that prevents the lifetime splitting. I believe the reason we get the right answer for setjmp is that the compiler always recognizes it as an intrinsic and does the following: 1. We mark the tuple representing the call to setjmp as having abnormal control flow. 2. We store the result of the call in a temp. 2a. We do some exotic stuff I don't understand to deal with the possibility of structured exception handling. 3. We generate a volatile label, noting that the label can be reached by a non-local goto. 4. We generate a fetch of the temp used to hold the result of the setjmp call. The user's code doesn't work as expected using sigsetjmp because we don't recognize it as an intrinsic and do all this fancy stuff. Workarounds would be to use setjmp instead of sigsetjmp, make the variables volatile, or compile -O0 (split lifetime analysis is documented as coming on at -O1). To fix the bug, the compiler would have to recognize sigsetjmp as well as setjmp and treat it similarly, which may be harder than it sounds since sigsetjmp has a different signature (two parameters instead of one), and the hairy code that deals with setjmp appears to have the routine's signature (and name?) sort of "wired in". Since sigsetjmp is not in the C standard, but is declared in , I think the mechanism for making it intrinsic would require an explicit #pragma intrinsic(sigsetjmp) We will look into resolving the above mentioned problem with sigsetjmp in future versions of Compaq C. Let us know if this helps. Thanks, -Jeff -- Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com DEC C and C++ | Nashua, NH ZK3-2/X29 | Jeff.Sullivan@compaq.com