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: Dimitry Andric
Subject: Re: [Qemu-devel] [PATCH v3] cpu-exec: Fix compiler warning (-Werror=clobbered)
Date: Sat, 26 Sep 2015 17:33:35 +0200

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?


> The code which should reload these variables causes compiler warnings
> with gcc 4.7 when compiler optimizations are enabled:
> 
> cpu-exec.c:204:15: error:
> variable ‘cpu’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> cpu-exec.c:207:15: error:
> variable ‘cc’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> cpu-exec.c:202:28: error:
> argument ‘env’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
> 
> Now this code is only used for compilers which need it
> (and gcc 4.5.x, x > 0 which does not need it but won't give warnings).
> 
> There were bug reports for clang and gcc 4.5.0, while gcc 4.5.1
> was reported to work fine without the reload code. For clang it
> is not clear which versions are affected, so simply keep the status quo
> for all clang compilations. This can be improved later.

Maybe you can just mark the variables in question volatile.  That will ensure 
they will not be indeterminate.

-Dimitry

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


reply via email to

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