http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59920

Carlos O'Donell <carlos at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |carlos at redhat dot com

--- Comment #3 from Carlos O'Donell <carlos at redhat dot com> ---
(In reply to Jakub Jelinek from comment #2)
> Is it valid to longjmp to a setjmp where the containing function hasn't
> terminated yet, but the scope in which the setjmp has been declared has been
> left already?

IMO this is undefined behaviour.

I can't convince myself that can be anything but that.

However, as written ISO C allows this, but it's allowance would require that
the entire state of the scope should be kept around for the duration of the
function just to satisfy the wording of setjmp/longjmp in the standard. I can't
justify that to myself.

An implementation might detect a setjmp in the scope, along with volatile or
non-automatic variables and then making sure the state of the scope is never
reused so a longjmp can return to it.

Reply via email to