This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] pthread_cleanup_push macro generates warning when -Wclobbered is set


On Wed, 15 Nov 2017, Florian Weimer wrote:

> > The "returns twice" information in GCC does not link the possible second
> > return to the lifetime of a particular object.
> 
> But the control flow in pthread_cleanup_push is such that for both returns,
> local objects of limited scope are referenced immediately, so the compiler
> could infer that.

As I see it, the point of the warning is to say that a second return might 
access a variable that has (through being in another loop iteration, in 
this case) changed.  If we reason that such an access would be invalid if 
in another loop iteration, and so we can't be in another loop iteration, 
when would the warning ever occur?

As far as the compiler can see, the __sigsetjmp call makes the jmp_buf 
contents escape, and at any subsequent point (before the function returns 
or a scope with a variably modified type is left) the function might 
return again - and if this is when the containing scope has reentered, the 
warning is meant to warn, not deduce that in fact that case does not 
occur.  Some more precise way of describing the possible times of a second 
return would be needed to make it valid not to warn.

> However, I still don't see how this matters here.  __cancel_routine and
> __cancel_arg are not addressable and not written to after initialization (and
> that's also true for the future argument in Paul's reproducer). This means
> that even with the POSIX interpretation if setjmp (where object lifetimes do
> not float outwards, and the address of the jump buffer matters), there is no
> wiggle room for the implementation to change the value of these variables.

The end of the containing scope causes their values to be uninitialized.

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]