Silence 'loss of data' warnings.
MODIFY
mrbgems/mruby-rational/src/rational.c
mrbgems/mruby-rational/src/rational.c
@@ -166,8 +166,8 @@ rational_new_i(mrb_state *mrb, mrb_int n, mrb_int d)
#include <math.h>
#if defined(MRB_INT32) || defined(MRB_USE_FLOAT32)
-#define frexp_rat frexpf
-#define ldexp_rat ldexpf
+#define frexp_rat(x,exp) frexpf((float)x, exp)
+#define ldexp_rat(x,exp) ldexpf((float)x, exp)
#define RAT_MANT_DIG FLT_MANT_DIG
#define RAT_INT_LIMIT 30
#define RAT_HUGE_VAL HUGE_VALF

MODIFY
src/backtrace.c
src/backtrace.c
@@ -41,6 +41,7 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, each_backtrace_func func, void *
mrb_callinfo *ci;
const mrb_irep *irep;
const mrb_code *pc;
+ uint32_t idx;
ci = &mrb->c->cibase[i];
@@ -57,10 +58,11 @@ each_backtrace(mrb_state *mrb, ptrdiff_t ciidx, each_backtrace_func func, void *
continue;
}
- loc.lineno = mrb_debug_get_line(mrb, irep, pc - irep->iseq);
+ idx = (uint32_t)(pc - irep->iseq);
+ loc.lineno = mrb_debug_get_line(mrb, irep, idx);
if (loc.lineno == -1) continue;
- loc.filename = mrb_debug_get_filename(mrb, irep, pc - irep->iseq);
+ loc.filename = mrb_debug_get_filename(mrb, irep, idx);
if (!loc.filename) {
loc.filename = "(unknown)";
}

MODIFY
src/codedump.c
src/codedump.c
@@ -42,7 +42,7 @@ print_lv_ab(mrb_state *mrb, const mrb_irep *irep, uint16_t a, uint16_t b)
}
static void
-print_header(mrb_state *mrb, const mrb_irep *irep, ptrdiff_t i)
+print_header(mrb_state *mrb, const mrb_irep *irep, uint32_t i)
{
int32_t line;
@@ -120,12 +120,12 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
ai = mrb_gc_arena_save(mrb);
i = pc - irep->iseq;
- next_file = mrb_debug_get_filename(mrb, irep, i);
+ next_file = mrb_debug_get_filename(mrb, irep, (uint32_t)i);
if (next_file && file != next_file) {
printf("file: %s\n", next_file);
file = next_file;
}
- print_header(mrb, irep, i);
+ print_header(mrb, irep, (uint32_t)i);
ins = READ_B();
switch (ins) {
CASE(OP_NOP, Z);

MODIFY
src/dump.c
src/dump.c
@@ -1043,7 +1043,7 @@ sym_operator_name(const char *sym_name, mrb_int len)
for (start = 0; table_size != 0; table_size/=2) {
idx = start+table_size/2;
op_sym = &operator_table[idx];
- cmp = len-op_sym->sym_name_len;
+ cmp = (int)(len-op_sym->sym_name_len);
if (cmp == 0) {
cmp = memcmp(sym_name, op_sym->sym_name, len);
if (cmp == 0) return op_sym->name;

MODIFY
src/vm.c
src/vm.c
@@ -279,8 +279,8 @@ cipush(mrb_state *mrb, mrb_int push_stacks, mrb_int acc,
ci->mid = mid;
mrb_vm_ci_proc_set(ci, proc);
ci->stack = ci[-1].stack + push_stacks;
- ci->argc = argc;
- ci->acc = acc;
+ ci->argc = (int16_t)argc;
+ ci->acc = (int16_t)acc;
ci->u.target_class = target_class;
return ci;
@@ -1282,7 +1282,7 @@ RETRY_TRY_BLOCK:
}
CASE(OP_JMPUW, S) {
- a = (pc - irep->iseq) + (int16_t)a;
+ a = (uint32_t)((pc - irep->iseq) + (int16_t)a);
CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {
struct RBreak *brk = (struct RBreak*)mrb->exc;
mrb_value target = mrb_break_value_get(brk);
@@ -1855,7 +1855,7 @@ RETRY_TRY_BLOCK:
}
/* format arguments for generated code */
- mrb->c->ci->argc = len + kd;
+ mrb->c->ci->argc = (int16_t)(len + kd);
/* clear local (but non-argument) variables */
if (irep->nlocals-blk_pos-1 > 0) {

Silence 'loss of data' warnings.