On Mon, Jun 10, 2013 at 11:32:22AM +0200, Jakub Jelinek wrote:
> On Mon, Jun 10, 2013 at 11:24:16AM +0200, Marek Polacek wrote:
> > > >@@ -4070,8 +4077,15 @@ cp_build_binary_op (location_t location,
> > > > {
> > > > enum tree_code tcode0 = code0, tcode1 = code1;
> > > > tree cop1 = fold_non_dependent_expr_sfinae (op1, tf_none);
> > > >+ cop1 = maybe_constant_value (cop1);
> > > >
> > > >- warn_for_div_by_zero (location, maybe_constant_value (cop1));
> > > >+ if (!processing_template_decl && tcode0 == INTEGER_TYPE
> > > >+ && (TREE_CODE (cop1) != INTEGER_CST
> > > >+ || integer_zerop (cop1)
> > > >+ || integer_minus_onep (cop1)))
> > > >+ doing_div_or_mod = true;
> > >
> > > Aren't you already doing this test in ubsan_instrument_division?
> >
> > Yep, I'll throw it out of cp/typeck.c.
>
> Note that the above one actually performs more than what you do in
> ubsan_instrument_division, because it works on maybe_constant_value result.
> So, perhaps typeck.c should ensure that the ubsan functions are always
> called with arguments passed through
> maybe_constant_value (fold_non_dependent_expr_sfinae (opX, tf_none)).
Ah, ok, will add it there. Thanks.
Marek