compiler icon indicating copy to clipboard operation
compiler copied to clipboard

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

Open Y-Less opened this issue 3 years ago • 2 comments

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:

  • Compiler version:
  • Command line arguments provided (or sampctl version):
  • Operating System:

Y-Less avatar Feb 06 '22 11:02 Y-Less

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.

Y-Less avatar Feb 06 '22 11:02 Y-Less

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.

Daniel-Cortez avatar Feb 09 '22 02:02 Daniel-Cortez