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: Request to merge Undefined Behavior Sanitizer in (take 2)


On 08/05/2013 07:24 AM, Marek Polacek wrote:
On Sat, Aug 03, 2013 at 12:24:32PM -0400, Jason Merrill wrote:
Where are the SAVE_EXPRs coming from?  It doesn't seem to me that x
needs to be wrapped in a SAVE_EXPR at all in this case.  For cases
where the SAVE_EXPR is needed and not used in the test, you could
add the SAVE_EXPR before the condition with a COMPOUND_EXPR.

Those SAVE_EXPRs are coming from c-typeck.c in this case:

   if (flag_sanitize & SANITIZE_UNDEFINED
       && current_function_decl != 0
       && (doing_div_or_mod || doing_shift))
     {
       /* OP0 and/or OP1 might have side-effects.  */
       op0 = c_save_expr (op0);
       op1 = c_save_expr (op1);

Yes, but why do we need to wrap op0 in a save_expr? That's only necessary if we're going to be evaluating it twice on the same path, but here it's only evaluated once on each path.

Jason


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