Hi all,
I would like to propose this patch to check for the return type of
binary operators to be a numeric type.
Not doing so can lead the compiler into funny crashes.
Does not introduce regressions running make check-jit.
OK for trunk?
Bests
Andrea
2019-06-09 Andrea Corallo [email protected]
* libgccjit.c (gcc_jit_context_new_binary_op): Check result_type to be a
numeric type.
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index e4f17f8..95a2c02 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -1345,6 +1345,10 @@ gcc_jit_context_new_binary_op (gcc_jit_context *ctxt,
a->get_type ()->get_debug_string (),
b->get_debug_string (),
b->get_type ()->get_debug_string ());
+ RETURN_NULL_IF_FAIL_PRINTF1 (
+ result_type->is_numeric (), ctxt, loc,
+ "result_type type: %s is not numeric",
+ result_type->get_debug_string ());
return (gcc_jit_rvalue *)ctxt->new_binary_op (loc, op, result_type, a, b);
}