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

Florian Weimer fweimer@redhat.com
Tue Nov 21 11:01:00 GMT 2017


On 11/21/2017 06:35 AM, Paul Eggert wrote:
> Joseph Myers wrote:
>> the warning
>> seems justified to me, in that the second return of __sigsetjmp might
>> result in undefined behavior from variables being accessed after the
>> containing block has exited, which is what the warning is about.
> 
> I'm with Florian on this. I don't see the warning as being justified.
> 
> Basically the warning is saying "Watch out! Since these variables are 
> not declared to be volatile, they might be trashed by longjmp!" You can 
> work around such problems by declaring the variables to be volatile.
> 
> Here, though, declaring the variables to be volatile would not fix the 
> problem that you describe. Because a longjmp makes them go out of scope, 
> they become uninitialized regardless of whether they're declared to be 
> volatile. So the warning is not appropriate here.

I think the standard assumes that storage for all local variables is 
allocated when the function is entered (or when a scope is entered with 
which contains a variable of variably modified type).  This is certainly 
an odd requirement.

Thanks,
Florian



More information about the Libc-alpha mailing list