On 12/03/2013 02:45 PM, Marek Polacek wrote:
You're right.  I wanted to use cp_save_expr and/or stabilize_expr, but
that didn't work out.  So I resorted to restrict the condition a bit
and only pass INDIRECT_REFs to the ubsan routine (which, after all,
has
   if (!INDIRECT_REF_P (init))
     return init;
And in that case, it seems we don't have to worry about multiple evaluation
of the initializer.

Hmm? You can have an INDIRECT_REF where the operand has side-effect, i.e "*f()" where f returns a pointer.

stabilize_expr ought to work. Your main problem with that was probably that you were trying to call it here, at which point init is just what the user wrote, whereas you want to wait until you have an expression with REFERENCE_TYPE. Try adding the instrumentation in store_init_value instead.

Jason

Reply via email to