From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20876 invoked by alias); 8 Jul 2014 05:36:03 -0000 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 Received: (qmail 20798 invoked by uid 48); 8 Jul 2014 05:35:56 -0000 From: "su at cs dot ucdavis.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug lto/61741] wrong code by LTO on x86_64-linux-gnu Date: Tue, 08 Jul 2014 05:36:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: lto X-Bugzilla-Version: 4.10.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: su at cs dot ucdavis.edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg00429.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61741 --- Comment #2 from Zhendong Su --- (In reply to Andi Kleen from comment #1) > char c = 0; > for (; a; a--) > for (; c >= 0; c++); > > Don't you rely on signed overflow which is undefined? No, there is no signed overflow since the variable c is a char so the increments are performed on int first and then cast back to char: (char) ((int) c + 1). The same also holds for short.