Fix the bug by the combination with `MRB_64BIT` and `MRB_INT32`.

Which is caused by `MRB_NAN_BOXING`.
parent cf2aabda
......@@ -934,14 +934,19 @@ dump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp)
{
if (p->tt & IREP_TT_NFLAG) { /* number */
switch (p->tt) {
case IREP_TT_INT32:
fprintf(fp, "{IREP_TT_INT32, {.i32=%" PRId32 "}},\n", p->u.i32);
break;
#ifdef MRB_64BIT
case IREP_TT_INT64:
fprintf(fp, "{IREP_TT_INT64, {.i64=%" PRId64 "}},\n", p->u.i64);
if (p->u.i64 < INT32_MIN || INT32_MAX < p->u.i64) {
fprintf(fp, "{IREP_TT_INT64, {.i64=%" PRId64 "}},\n", p->u.i64);
}
else {
fprintf(fp, "{IREP_TT_INT32, {.i64=%" PRId64 "}},\n", p->u.i64);
}
break;
#endif
case IREP_TT_INT32:
fprintf(fp, "{IREP_TT_INT32, {.i32=%" PRId32 "}},\n", p->u.i32);
break;
case IREP_TT_FLOAT:
if (p->u.f == 0) {
fprintf(fp, "{IREP_TT_FLOAT, {.f=%#.1f}},\n", p->u.f);
......
......@@ -1018,10 +1018,16 @@ RETRY_TRY_BLOCK:
regs[a] = mrb_fixnum_value((mrb_int)pool[b].u.i32);
break;
case IREP_TT_INT64:
#if defined(MRB_INT64) && defined(MRB_64BIT)
#if defined(MRB_INT64)
regs[a] = mrb_fixnum_value((mrb_int)pool[b].u.i64);
break;
#else
#if defined(MRB_64BIT)
if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {
regs[a] = mrb_fixnum_value((mrb_int)pool[b].u.i64);
break;
}
#endif
{
mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "integer overflow");
mrb_exc_set(mrb, exc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment