Skip to content

fix(vm): preserve int64/uint64 precision in arithmetic#946

Open
eyupcanakman wants to merge 2 commits intoexpr-lang:masterfrom
eyupcanakman:fix/int64-arithmetic-overflow-804
Open

fix(vm): preserve int64/uint64 precision in arithmetic#946
eyupcanakman wants to merge 2 commits intoexpr-lang:masterfrom
eyupcanakman:fix/int64-arithmetic-overflow-804

Conversation

@eyupcanakman
Copy link

Arithmetic between two int64 values (or two uint64 values) goes through int, which truncates on 32-bit platforms. The generated runtime helpers had no specialization for 64-bit types.

The code generator now emits int64 cases when both operands are signed and at least one is int64, and uint64 when both are unsigned and at least one is uint64. Mixed signed/unsigned stays as int.

Fixes #804

…32-bit

On 32-bit architectures, arithmetic operations between int64 operands
silently truncated to int (32-bit), causing overflow. Fix the code
generator to promote result type to int64/uint64 when either operand
is int64/uint64.

Fixes expr-lang#804
…ness

Avoid mixed-sign regression where int64 + uint64 would incorrectly
promote to uint64, causing wrong results for negative values.
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

Successfully merging this pull request may close these issues.

Arithmetic operations choose arch-dependant type and overflow in 32bit

1 participant