When an enum contains an array (including but not limited to another enum), copying from this array to either a normal array or an array inside another enum results in incorrect code.
Assigning from an array to an array inside an enum seems to be the only thing that works.
Minimal complete verifiable example:
#include <a_samp>
enum E
{
E1[32]
}
public OnFilterScriptInit()
{
new e1[E], e2[E];
new a[32];
a = e1[E1];
e2[E1] = e1[E1];
}
The assignment to a also produces a warning:
warning 229: index tag mismatch (symbol "e1"): expected tag none ("_"), but found "E"
The last two lines produce this assembly code:
; line d
break ; 6c
addr.pri fffffe80
push.pri
addr.pri ffffff80
load.i
pop.alt
movs 80
;$exp
; line e
break ; 94
addr.pri ffffff00
push.pri
addr.pri ffffff80
load.i
pop.alt
stor.i
In the first case, movs is correctly generated, but it seems like the compiler treats e1 like a two-dimensional array and tries to find the offset in the non-existent header. In the second case, movs isn't even generated at all, and instead it seems just like reassigning cells.
Workspace Information:
Compiler version: 3.10.9
Command line arguments provided (or sampctl version): -;+ -d3 -(+ -Z (different -O levels don't change the result)
Issue description:
When an enum contains an array (including but not limited to another enum), copying from this array to either a normal array or an array inside another enum results in incorrect code.
Assigning from an array to an array inside an enum seems to be the only thing that works.
Minimal complete verifiable example:
The assignment to
a
also produces a warning:The last two lines produce this assembly code:
In the first case,
movs
is correctly generated, but it seems like the compiler treatse1
like a two-dimensional array and tries to find the offset in the non-existent header. In the second case,movs
isn't even generated at all, and instead it seems just like reassigning cells.Workspace Information:
-;+ -d3 -(+ -Z
(different-O
levels don't change the result)