From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3897 invoked by alias); 6 Jul 2010 09:33:50 -0000 Received: (qmail 3752 invoked by uid 48); 6 Jul 2010 09:33:17 -0000 Date: Tue, 06 Jul 2010 09:33:00 -0000 Message-ID: <20100706093317.3751.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c/44828] possible integer wrong code bug In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "jakub 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: 2010-07/txt/msg00533.txt.bz2 ------- Comment #2 from jakub at gcc dot gnu dot org 2010-07-06 09:33 ------- Not sure whether the testcase is valid or not. The multiplication using char variables on both sides (and likewise for result) is: -54 * -56 (= 3024), but (char) 3024 is -48. For int that would be clear undefined behavior, but for char the multiplication is promoted to int, so it is (char) (int * int). *.ccp1 has: char D.2741; char D.2741; char si2; int D.2727; char D.2726; int a.0; : a.0_2 = a; D.2726_3 = (char) a.0_2; D.2727_4 = (int) D.2726_3; si2_11 = (char) D.2727_4; D.2741_12 = si2_11 * -56; D.2741_13 = D.2741_12; D.2741_7 = D.2741_13; if (D.2741_7 > 0) but forwprop1 uses if (si2_11 < 0) test instead. If the testcase is valid, we shouldn't assume undefined overflow for char and short operations. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44828