Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-15 Thread Jason Merrill
On 08/15/2013 07:04 AM, Marek Polacek wrote: if any of the operands is wrapped in SAVE_EXPR, we get an -Wuninitialized warning. So, what I did is to evaluate the op0 always in the condition, like "if (op0, )", which is safe and all the uninitialized warnings are gone, That sounds fine. now t

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-15 Thread Jason Merrill
OK. Jason

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-15 Thread Marek Polacek
On Wed, Aug 07, 2013 at 04:58:03PM +0200, Marek Polacek wrote: > I actually don't know what I prefer more, but if you like this version > more, I'll go with it. Maybe this is better because we don't have to > create SAVE_EXPR and also we avoid one fold_build call. Thanks, Not creating the SAVE_E

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-15 Thread Marek Polacek
Ping. On Wed, Aug 07, 2013 at 06:12:58PM +0200, Marek Polacek wrote: > On Wed, Aug 07, 2013 at 10:24:59AM -0400, Jason Merrill wrote: > > On 08/07/2013 06:06 AM, Marek Polacek wrote: > > >I might've misunderstood what you mean. If we drop the hunk above, > > >then we'll call > > > error ("%q+

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-07 Thread Marek Polacek
On Wed, Aug 07, 2013 at 10:24:59AM -0400, Jason Merrill wrote: > On 08/07/2013 06:06 AM, Marek Polacek wrote: > >I might've misunderstood what you mean. If we drop the hunk above, > >then we'll call > > error ("%q+E is not a constant expression", t); > >so, we'll print "is not a constant expre

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-07 Thread Marek Polacek
On Tue, Aug 06, 2013 at 05:24:08PM -0400, Jason Merrill wrote: > 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 th

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-07 Thread Jason Merrill
On 08/07/2013 06:06 AM, Marek Polacek wrote: I might've misunderstood what you mean. If we drop the hunk above, then we'll call error ("%q+E is not a constant expression", t); so, we'll print "is not a constant expression" no matter what Yes, that's fine; 1/0 is not a constant expression,

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-07 Thread Marek Polacek
On Tue, Aug 06, 2013 at 07:07:27PM -0400, Jason Merrill wrote: > >I think, what we could do, is to tweak verify_constant like this: > > > >+ /* This is to handle e.g. the goofy 'case 0 * (1 / 0)' case. */ > >+ if (flag_sanitize & SANITIZE_UNDEFINED > >+ && TREE_CODE (t) == CALL_EXPR > >+

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-06 Thread Jason Merrill
On 08/06/2013 10:42 AM, Marek Polacek wrote: Hm, actually, we can't easily fold the call to the sanitize function away, I'm afraid, if we want to do it for the 'case ' case. When we hit the DIV_EXPR in 'case 0 * (1 / 0)', the ubsan_instrument_division gets 1 as a first argument and 0 as a second

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-06 Thread Jason Merrill
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 tes

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-06 Thread Marek Polacek
On Wed, Jul 31, 2013 at 02:52:39PM -0400, Jason Merrill wrote: > >http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01536.html > > Here, the C++ compiler is wrong to fold away the division by zero, > but given that bug the folding ought to also eliminate the call to > the sanitize function. Seems like

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-05 Thread Marek Polacek
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 th

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-03 Thread Jason Merrill
On 08/01/2013 02:06 PM, Marek Polacek wrote: SAVE_EXPRs are evaluated only once; in that COMPOUND_EXPR, when we first encounter SAVE_EXPR and call get_initialized_tmp_var, we get temporary value for it, x.2. Then, in the second part of the COMPOUND_EXPR, we meet SAVE_EXPR again, but it already

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-08-01 Thread Marek Polacek
On Wed, Jul 31, 2013 at 02:52:39PM -0400, Jason Merrill wrote: > On 07/31/2013 01:33 PM, Marek Polacek wrote: > >There are still at least two issues though, which is why > >bootstrap with -fsanitize=undefined fails: > > > >http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01480.html > > This looks like

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-07-31 Thread Jason Merrill
On 07/31/2013 01:33 PM, Marek Polacek wrote: There are still at least two issues though, which is why bootstrap with -fsanitize=undefined fails: http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01480.html This looks like a serious bug, properly caught by -Wuninitialized. When sanitizing, in .uni

Re: Request to merge Undefined Behavior Sanitizer in (take 2)

2013-07-31 Thread Marek Polacek
On Thu, Jul 25, 2013 at 04:13:29PM -0400, Jason Merrill wrote: > Otherwise, looks fine. If nobody else has comments, go ahead and > check it in next week. I had to make a few changes since, particularly: - [ubsan] Add -static-libubsan http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01467.html