pawn-lang / compiler

Pawn compiler for SA-MP with bug fixes and new features - runs on Windows, Linux, macOS
Other
301 stars 71 forks source link

`__emit addr.u.pri` doesn't work on local arrays. #695

Open Y-Less opened 2 years ago

Y-Less commented 2 years ago

Issue description:

Minimal complete verifiable example (MCVE):

native printf(const format[], {Float, _}:...);

main()
{
    new arr[4];
    new addr = __emit(addr.u.pri arr);
    printf("%d", addr);
}

Gives an error. It really seems like this should work in the same way as normal locals.

Workspace Information:

Y-Less commented 2 years ago

Fortunately using arr[0] does seem to compile to the minimal code:

#pragma option -a

native printf(const format[], {Float, _}:...);

main()
{
    new arr[4];
    new addr = __emit(addr.u.pri arr[0]);
    printf("%d", addr);
}

Gives:

    stack fffffffc
    addr.pri fffffff0
    stor.s.pri ffffffec

It is just a bit awkward.

Daniel-Cortez commented 2 years ago

A duplicate of #677. I'll quote my answer from there, for convenience:

Yes, this is intended behavior. Universal pseudo-opcodes were created with the main purpose of being used in macros and handling the input from users (and by "users" I mean just regular users, not library writers), so their operands are supposed to be single cells.