On Tue, Jun 11, 2013 at 10:40:12PM +0200, Marek Polacek wrote: > On Tue, Jun 11, 2013 at 10:33:25PM +0200, Jakub Jelinek wrote: > > That means you probably should move the function call down in > > cp_build_binary_op (resp. C counterpart), after the arguments are converted > > to result_type? > > Ok, certainly. Seems the arguments are converted here: > > if (! converted) > { > if (TREE_TYPE (op0) != result_type) > op0 = cp_convert_and_check (result_type, op0, complain); > if (TREE_TYPE (op1) != result_type) > op1 = cp_convert_and_check (result_type, op1, complain); > > if (op0 == error_mark_node || op1 == error_mark_node) > return error_mark_node; > } > > I'll move the instrumentation after the hunk above. And then > in ubsan_instrument_division I might want to have just > tree type = TREE_TYPE (op0);, maybe together with an assert like > gcc_assert (TREE_TYPE (op0) == TREE_TYPE (op1).
There is another thing to solve BTW, op0 and/or op1 might have side-effects, if you are going to evaluate them more than once, they need to be surrounded into cp_save_expr resp. c_save_expr. Jakub