qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] cpu-exec: Fix compiler warning (-Werror=clob


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v3] cpu-exec: Fix compiler warning (-Werror=clobbered)
Date: Sat, 26 Sep 2015 09:19:01 -0700

On 26 September 2015 at 08:33, Dimitry Andric <address@hidden> wrote:
> On 26 Sep 2015, at 13:23, Stefan Weil <address@hidden> wrote:
>>
>> Reloading of local variables after sigsetjmp is only needed for some
>> buggy compilers.
>
> I don't think the compilers are buggy; any non-volatile local variable that 
> is changed between setjmp() and longjmp() is indeterminate.  Quoting C99 
> 7.13.2.1:
>
>         • All accessible objects have values, and all other components of the 
> abstract machine(209) have state, 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.
>
> Can you be 100% sure these variables are never changed anywhere after the 
> setjmp() call?

Yes; they're only set on entry to the function before setjmp().
This is why the compilers in question are buggy -- the variables
haven't been changed, so they should be preserved, but some
compilers seemed to trash them. Thus the "restore values"
code which is working around the compiler bug.

Unfortunately now newer compilers are complaining via Wclobbered
about the "restore values" code (they're not smart enough to
be able to tell that that bit of code is only executed after
a longjmp and before we go back around to do the next setjmp).

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]