bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#42360: [feature/native-comp] miscompilation(?) of functions with non


From: Stefan Monnier
Subject: bug#42360: [feature/native-comp] miscompilation(?) of functions with non local exits
Date: Wed, 15 Jul 2020 15:17:27 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> Three options:
>
>   1- Because setq is evaluated the expression should always evaluate to
>   t.
>
>   2- Unwinding the original state of the stack is restored, when it was
>   saved 'x' was nil so the expression should evaluate to nil.
>
>   3- This is unspecified.

Very definitely (1)!

We don't want to introduce into Elisp the kind of messy semantics you
get in C with non-volatile variables and longjmp.

> FYI 1 implies C register variables cannot be used to implement Lisp
> local variable if non local exits are present.

IIUC, the problem only occurs for those vars which have
a `condition-case` (or `unwind-protect` or `catch`) in their scope and
where the var is modified within that construct and that a non-local
exit can jump to the end of that construct after the var was thus
modified, and that the var is used after the construct.

This should be fairly rare (not sure if those cases can easily be
written differently, OTOH).    The compiler could replace those vars
by boxing them inside a cons-cell (so the register-stored C var is
immutable and contains a pointer to a cons cell which holds the real
value in the `car`), just like we do with mutated Elisp vars captured
by closures.


        Stefan






reply via email to

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