This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Implement Undefined Behavior Sanitizer (take 2)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]