diff --git a/CHANGELOG.md b/CHANGELOG.md index 16d5dc9a..bce04eef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ Features Bug Fixes +- Fixed a bug in the oprimized numeric comparison operators when comparing a double with a bignum, that could lead to undefined behavior. - Fixed `make_empty_bytevector` and `make_c_opaque` parameters on `(cyclone foreign)`. ## 0.18 - June 8, 2020 diff --git a/runtime.c b/runtime.c index be64d352..00c379b7 100644 --- a/runtime.c +++ b/runtime.c @@ -1818,7 +1818,7 @@ object FUNC_FAST_OP(void *data, object x, object y) { \ } else if (tx == -1 && ty == bignum_tag) { \ return Cyc_bignum_cmp(BN_CMP, x, tx, y, ty) ? boolean_t : boolean_f; \ } else if (tx == double_tag && ty == bignum_tag) { \ - return (double_value(x)) OP mp_get_double(&bignum_value(x)) ? boolean_t : boolean_f; \ + return (double_value(x)) OP mp_get_double(&bignum_value(y)) ? boolean_t : boolean_f; \ } else if (tx == complex_num_tag && ty == complex_num_tag) { \ return ((complex_num_value(x)) == (complex_num_value(y))) ? boolean_t : boolean_f; \ } else if (tx == complex_num_tag && ty != complex_num_tag) { \