Bug 33565 - [4.3 regression] spurious warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true
Summary: [4.3 regression] spurious warning: assuming signed overflow does not occur w...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2007-09-26 16:45 UTC by Serge Belyshev
Modified: 2007-09-27 17:37 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-09-26 19:04:56


Attachments
Patch (1.24 KB, patch)
2007-09-26 17:54 UTC, Ian Lance Taylor
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Serge Belyshev 2007-09-26 16:45:27 UTC
with -O2 -Wall:

void f (int m, int n)
{
  int j;
 
  for (j = m; j	< m + 10 && j <	n; j ++)
    do_something (j);
 
}

t.c:2: warning: assuming signed overflow does not occur when assuming that (X + c) >= X is always true

(also note useless line number)
Comment 1 Ian Lance Taylor 2007-09-26 17:54:01 UTC
Created attachment 14253 [details]
Patch

I'm testing this patch.
Comment 2 Andrew Pinski 2007-09-26 19:04:56 UTC
Confirmed.
Comment 3 ian@gcc.gnu.org 2007-09-27 17:31:47 UTC
Subject: Bug 33565

Author: ian
Date: Thu Sep 27 17:31:34 2007
New Revision: 128840

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128840
Log:
./:
	PR tree-optimization/33565
	* tree-ssa-loop-ch.c (copy_loop_headers): Set TREE_NO_WARNING on
	assignments of comparisons.
	* tree-ssa-sccvn.c (simplify_binary_expression): Add stmt
	parameter.  Change caller.  Defer overflow warnings around call to
	fold_binary.
	* fold-const.c (fold_undefer_overflow_warnings): Don't warn if
	TREE_NO_WARNING is set on the statement.
	* tree-ssa-forwprop.c
	(tree_ssa_forward_propagate_single_use_vars): Don't test
	TREE_NO_WARNING when calling fold_undefer_overflow_warnings.
	* tree-cfg.c (fold_cond_expr_cond): Likewise.
testsuite/:
	PR tree-optimization/33565
	* gcc.dg/Wstrict-overflow-20.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/Wstrict-overflow-20.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/fold-const.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-cfg.c
    trunk/gcc/tree-ssa-forwprop.c
    trunk/gcc/tree-ssa-loop-ch.c
    trunk/gcc/tree-ssa-sccvn.c

Comment 4 Ian Lance Taylor 2007-09-27 17:37:05 UTC
Fixed.