From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <35390bbbdd8b709f09d36bc834099340.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199802241042.LAA02008@stefan.sime.com> Date: Mon, 23 Feb 1998 16:31:43 -0800 From: Richard Henderson Subject: Re: gcc compiler warning In-Reply-To: <199802231437.JAA04904@rrdjazz.nist.gov> On Mon, Feb 23, 1998 at 09:37:14AM -0500, Przemek Klosowski wrote: > Register-based local variables are not guaranteed to be preserved > across longjump (and also I guess vfork); in other words if you do > setjmp, and then longjmp to it, you aren't guaranteed to see the > values of register-based local variables as they were at time of > setjmp; this is because setjmp/longjmp save/restore the stack only. No, the real problem is that longjmp _does_ restore the call-saved registers to the contents they had at setjmp, when what is wanted is a real stack-unwind as is possible when the language supports exceptions. So in jmp_buf buf; register int i = 1; if (setjmp(buf)) printf("%d\n", i); else { i = 10; longjmp(buf, 1); } if i is allocated to a call-saved register, you get 1, if not, you get 10. The warning reminds you that that the only way to get consistent results is to declare i volatile. In which case you get 10. r~ -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com