From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 263593858D37; Sat, 25 Jul 2020 09:13:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 263593858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1595668417; bh=mcaVMrqEYLnHHYwa7FOTmnKnRkTrX7/fKFSoLBgnT9c=; h=From:To:Subject:Date:From; b=Cd0R0y64p3e1DhTsF5cTyFrHYLtBbQgIOhtjXgC6SjdmqT31NDFCmLEb+wYfnxA0k 12VnlIb7tzAcF0s2bc3U6etTbB6s/l/3Gp9VMRlbeNmi609+XISczEgi3nU2JXp6Iz wU+AmPVxyGHf+RdDfy1F9LA81kg0hTLRMsUQ+nns= From: "570070308 at qq dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/96317] New: [8/9/10/11] Int compare optimizations make some errors Date: Sat, 25 Jul 2020 09:13:36 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: 570070308 at qq dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jul 2020 09:13:37 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96317 Bug ID: 96317 Summary: [8/9/10/11] Int compare optimizations make some errors Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: 570070308 at qq dot com Target Milestone: --- for the code: signed int a=3D2147483647; if( (signed int)( (signed int)a + (signed int)1 ) < (signed int)2147483= 647 ) { printf("111\n"); } if( (signed int)( (signed int)a + (signed int)1 ) < (signed int)2147483= 646 ) { printf("222\n"); } signed int b=3D2147483646; if( (signed int)( (signed int)a + (signed int)1 ) < (signed int)b ) { printf("333\n"); } The result is: 111 333 I have checked the assembly files. It seems that the compiler optimize the a+1<2147483646 to a<=3D2147483644. There are some other similar situations = in compartion of <=3D,>,>=3D. I think it is better to change the ways or give = out a warning.=