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

Integer promotion problems, part deux #120

Closed
d0c-s4vage opened this issue Jan 19, 2020 · 0 comments · Fixed by #121
Closed

Integer promotion problems, part deux #120

d0c-s4vage opened this issue Jan 19, 2020 · 0 comments · Fixed by #121
Assignees
Labels
bug concrete-issue An actionable, concrete issue that includes stack trace & technical details. Usually post-triage

Comments

@d0c-s4vage
Copy link
Owner

After creating the issue, checkboxes will appear where [] label exist in the
markdown. You can check/uncheck them to fill out the environment section.

Describe the bug

Pfp doesn't correctly handle integer promotion. E.g. this should print 10,896

local ubyte cur = 7;
local uint test1 = (uint)(10);
local uint test2 = (uint)((cur & 0x7f) << 7);
Printf("%u,%u", test1, test2);

Currently, the output in pfp is 10,128.

Stack Trace

None

Expected Behavior

Should have the same integer promotion as C and 010 Editor

Implementation/Fix Notes/Thoughts

In the statement local uint test2 = (uint)((cur & 0x7f) << 7);, cur and 0x7f are treated as ubyte types and aren't promoted until the cast occurs. The promotion needs to happen before operations occur, so that the & and the << binary operators operate on the target cast type uint, and not the original types (ubyte)

@d0c-s4vage d0c-s4vage added bug concrete-issue An actionable, concrete issue that includes stack trace & technical details. Usually post-triage labels Jan 19, 2020
@d0c-s4vage d0c-s4vage self-assigned this Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug concrete-issue An actionable, concrete issue that includes stack trace & technical details. Usually post-triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant