From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrV56-0001Xn-DH for qemu-devel@nongnu.org; Thu, 11 Aug 2011 09:13:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrV55-00087v-2a for qemu-devel@nongnu.org; Thu, 11 Aug 2011 09:13:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40680) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrV54-00087o-LL for qemu-devel@nongnu.org; Thu, 11 Aug 2011 09:13:51 -0400 Message-ID: <4E43D585.90907@redhat.com> Date: Thu, 11 Aug 2011 15:13:41 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <4E0CA885.2050308@siemens.com> <4E0ECDDB.9030001@web.de> <4E43C80B.1050300@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] tcg: Reload local variables after return from longjmp List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: Blue Swirl , TeLeMan , Jan Kiszka , qemu-devel , David Gilbert On 08/11/2011 02:40 PM, Peter Maydell wrote: > "All accessible objects have values [...] as of the time the longjmp > function was called, except that the values of objects of automatic > storage duration that are local to the function containing the > invocation of the corresponding setjmp macro that do not have > volatile-qualified type and have been changed between the setjmp > invocation and longjmp call are indeterminate." > -- C99 section 7.13.2.1 para 3. > > So variables may only be destroyed if they are all of: > * local to the function calling setjmp > * not volatile > * changed between setjmp and longjmp I didn't remember this third part. Thanks for bringing up facts. :) > We don't change env between the setjmp and longjmp so the compiler > should not trash it. (Indeed according to Jan in > http://lists.gnu.org/archive/html/qemu-devel/2011-07/msg00144.html > -Wclobbered doesn't complain about this code.) Then it's a compiler bug, not smartness. Making env volatile (or making a volatile copy if there is a performance impact) should still be enough to work around it. Paolo