Page MenuHomePhabricator

unit test for OP_DIV
AbandonedPublic

Authored by movrcx on Feb 15 2018, 00:54.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

Unit tests for OP_DIV

Co-authored-by: Marcos Mayorga <mm@mm-studios.com>

Test Plan

N/A

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 1846
Build 1879: arc lint + arc unit

Event Timeline

In C++ there is a corner-case where the maximal negative integer, divided by -1, overflows. Is there something similar in script?

In C++ there is a corner-case where the maximal negative integer, divided by -1, overflows. Is there something similar in script?

When the operands get loaded into CScriptNum they are allowed up to 4 bytes. They get allocated into an int64_t so there are no overflow issues. If the operation results in an overflow of the 4 bytes then the result gets pushed onto the stack but future arithmetic operations intentionally fail.

CScriptNum bn2(stacktop(-1), fRequireMinimal);