https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108117

--- Comment #8 from Feng Xue <fxue at os dot amperecomputing.com> ---
(In reply to Andrew Pinski from comment #7)
> (In reply to Feng Xue from comment #6)
> > (In reply to Andrew Pinski from comment #2)
> > > https://en.cppreference.com/w/c/program/setjmp
> > 
> > I think that most programmers are not aware of this, neither I for sure.
> > Usage of volatile here is not that intuitive as for purpose of
> > multi-execution synchronization
> 
> You should read up on
> https://en.cppreference.com/w/cpp/utility/program/signal too.

>From viewpoint of programmer, setjmp/longjmp is somewhat similar to C++
exception handling, which happens in one logical execution context, while
signal implies two  unrelated contexts.

In another angle, because gcc already model control flow and SSA web for
setjmp/longjmp, explicit volatile specification is not really needed. But
signal mechanism is kind of asynchronous exception, for which it is impractical
for compiler to do that, so volatile is must.

Reply via email to