If you have two variables in different states, then use them both in a function that is in both states, they may end up pointing to the same memory address.
Two variables in different states should never be called at the same time, so they can share memory. However, a function can be declared in multiple states at once using <state:a, state:b>, which means that a variable in state:a can be used, as can a variable in state:b. In this case, they should be marked as possibly co-existent, and thus should not be collocated.
CODE 0 ; 0
;program exit point
halt 0
;exit point for functions called from the wrong state
l.0 ; 8
halt d
DATA 0 ; 0
dump 0 ; automaton (anonymous)
dump 0 ; automaton tt
CODE 0 ; 10
load.pri 4 ; Func
switch 2
l.2 ; 20
casetbl
case 2 0
case 1 1
case 2 1
DATA 0 ; 8
dumpn 0 1
CODE 0 ; 3c
l.1 ; 3c
proc ; Func
; line c
; line d
const.pri 5
stor.pri 8
;$exp
; line e
const.pri 6
stor.pri 8
;$exp
zero.pri
retn
proc ; main
; line 13
; line 14
push.c 0
call .Func
;$exp
zero.pri
retn
STKSIZE 1000
The important part is here:
; line d
const.pri 5
stor.pri 8
; line e
const.pri 6
stor.pri 8
Where two different values are written to the same memory location.
Issue description:
If you have two variables in different states, then use them both in a function that is in both states, they may end up pointing to the same memory address.
Two variables in different states should never be called at the same time, so they can share memory. However, a function can be declared in multiple states at once using
<state:a, state:b>
, which means that a variable instate:a
can be used, as can a variable instate:b
. In this case, they should be marked as possibly co-existent, and thus should not be collocated.Minimal complete verifiable example (MCVE):
Generated code:
The important part is here:
Where two different values are written to the same memory location.