This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Implement Undefined Behavior Sanitizer (take 2)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Marc Glisse <marc dot glisse at inria dot fr>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 10 Jun 2013 11:32:22 +0200
- Subject: Re: [RFC] Implement Undefined Behavior Sanitizer (take 2)
- References: <20130605175728 dot GD4160 at redhat dot com> <20130605191910 dot GV1493 at tucnak dot redhat dot com> <20130608164348 dot GF4160 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1306081915200 dot 3960 at laptop-mg dot saclay dot inria dot fr> <20130610092416 dot GI4160 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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)).
Jakub