Repository navigation
Commit ea8dafa
authored
fix undefined double to int64 cast in the script complement operator (#1239)
The ~ operator in ExprUnaryArithmetic::evaluate guarded the cast of its
double operand to int64_t with a hand-written range comparison. NaN passes
it (every comparison is false) and so does exactly 2^63, because
double(INT64_MAX) rounds up to 2^63; the following static_cast is then
undefined behavior (UBSan float-cast-overflow). Fractional operands were
also truncated silently, while the binary bitwise operators reject them.
Use the checked Any::cast<int64_t> the binary bitwise operators already
use, so these operands raise the existing RuntimeError instead.1 parent 03ec870 commit ea8dafa
2 files changed
Lines changed: 31 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
132 | | - | |
133 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
134 | 143 | | |
135 | 144 | | |
136 | 145 | | |
137 | | - | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
670 | 670 | | |
671 | 671 | | |
672 | 672 | | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
673 | 693 | | |
674 | 694 | | |
675 | 695 | | |
| |||
0 commit comments