Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Y-Less opened this issue Feb 6, 2022 · 2 comments
Open

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

Y-Less opened this issue Feb 6, 2022 · 2 comments

Comments

@Y-Less
Copy link
Member

Y-Less commented Feb 6, 2022

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
Copy link
Member Author

Y-Less commented Feb 6, 2022

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants