From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23255 invoked by alias); 26 Nov 2006 19:27:34 -0000 Received: (qmail 23197 invoked by uid 48); 26 Nov 2006 19:27:20 -0000 Date: Sun, 26 Nov 2006 19:27:00 -0000 Message-ID: <20061126192720.23196.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/19978] overflow in expression of constants should not cause multiple warnings In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "manu at gcc dot gnu dot org" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2006-11/txt/msg02294.txt.bz2 ------- Comment #4 from manu at gcc dot gnu dot org 2006-11-26 19:27 ------- (In reply to comment #3) > (In reply to comment #2) > > The problem is that we reset TREE_OVERFLOW: > > It would seem it overflows incremented, and underflow's decremented, > only a terminal non-zero count would represent an over/underflow for > addition/subtraction, (as an intermediate over/underflow is not observable)? > No. 1 - INT_MAX is not underflow or overflow. For example: int f2 (void) { return INT_MAX + 1 - 1; } gives also two "integer overflow in expression" warnings. Actually, I think the problem is that somewhere TREE_OVERFLOW() is set whenever TREE_CONSTANT_OVERFLOW() is 1. After the first warning is emitted, TREE_OVERFLOW() is set to 0 but TREE_CONSTANT_OVERFLOW() remains 1. When the next part of the expression is handled TREE_OVERFLOW() is set again because TREE_CONSTANT_OVERFLOW is still 1, so the warning is emitted a second time. For example: return INT_MAX + 1 - 1 + 1 - 1 + 1 - 1; generates 6 warnings. Is this the desired behaviour? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19978