From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E3BE63858C53; Sun, 19 Mar 2023 12:15:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3BE63858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679228157; bh=jhepRbWfdo2GMzgUA4R0pihuI5g0Wr9KgEXkx/lYPFM=; h=From:To:Subject:Date:From; b=t5AXGFtjIRArSOCroi7Cy8ptwlQBe6IO3hCTud+TI/U9CEf8XngTmGlN0UAGR6tuy ok3GZivt/dczCQ1Y+/cYRsGj6j+VVtUQn6GbNruDjra3ilJivBHahs8ApsSBXJeinv 2n1kCv/4qIfRgtjgvO9ZF5PrfrVcodtKVOEa7MWI= From: "geoffreydgr at icloud dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug analyzer/109193] New: GCC Static Analyzer does not know 1-a > 0-b" in the true branch of "if (a < b && 0 < a) " Date: Sun, 19 Mar 2023 12:15:57 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: analyzer X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: geoffreydgr at icloud dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: dmalcolm 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109193 Bug ID: 109193 Summary: GCC Static Analyzer does not know 1-a > 0-b" in the true branch of "if (a < b && 0 < a) " Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: analyzer Assignee: dmalcolm at gcc dot gnu.org Reporter: geoffreydgr at icloud dot com Target Milestone: --- I found a problem that GCC Static Analyzer does not know 1-a > 0-b" (line 1= 2) in the true branch of "if (a < b && 0 < a) ", but it knows =E2=80=9C0-a > 0= -b" (line 11) . I run gcc (trunk) with options -fanalyzer -O0. See it live: https://godbolt.org/z/6MjobMqnM Input: ``` #include #include int foo(int a, int b) { if ((a -b); // Add a positive number after the negation __analyzer_eval(0-a > 0-b); __analyzer_eval(1-a > 0-b); __analyzer_eval(1-a > 1-b); __analyzer_eval(2-a > 0-b); __analyzer_eval(2-a > 1-b); __analyzer_eval(2-a > 2-b); } } ``` Output: ``` : In function 'foo': :7:9: warning: implicit declaration of function '__analyzer_eval' [-Wimplicit-function-declaration] 7 | __analyzer_eval(!(a:7:9: warning: TRUE 7 | __analyzer_eval(!(a:8:9: warning: TRUE 8 | __analyzer_eval(-a > -b); | ^~~~~~~~~~~~~~~~~~~~~~~~ :11:9: warning: TRUE 11 | __analyzer_eval(0-a > 0-b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ :12:9: warning: UNKNOWN 12 | __analyzer_eval(1-a > 0-b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ :13:9: warning: TRUE 13 | __analyzer_eval(1-a > 1-b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ :14:9: warning: UNKNOWN 14 | __analyzer_eval(2-a > 0-b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ :15:9: warning: UNKNOWN 15 | __analyzer_eval(2-a > 1-b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ :16:9: warning: TRUE 16 | __analyzer_eval(2-a > 2-b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ Compiler returned: 0 ```=