From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B174D385803C; Sun, 31 Jan 2021 12:23:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B174D385803C From: "oleg.pekar.2017 at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/98900] New: Wrong static analyses warning when optimisation is on Date: Sun, 31 Jan 2021 12:23:35 +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: 8.3.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: oleg.pekar.2017 at gmail 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 attachments.created 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: Sun, 31 Jan 2021 12:23:35 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98900 Bug ID: 98900 Summary: Wrong static analyses warning when optimisation is on Product: gcc Version: 8.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: oleg.pekar.2017 at gmail dot com Target Milestone: --- Created attachment 50095 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50095&action=3Dedit Preprocessor output for source file test1.c gcc version: 8.3.1 system type: RedHat 8.1, Kernel 4.18.0-147.3.1.el8_1.x86_64 Problem: Wrong static analyses warning when optimisation is on. Input source: attached test1.i Description: in this code address of a variable local to a block is used outside of the block. With no optimisation there's no warning while the code still can cause a problem. But with optimisation static analyses provides a confusing warning - it complains about a variable not used in the context of the warning. Command line with no optimisation: gcc -Wall -save-temps test1.c Output: nothing Command line with optimisation: gcc -Wall -save-temps -O2 test1.c Output:=20 test1.c: In function =E2=80=98main=E2=80=99: test1.c:11:7: warning: =E2=80=98x=E2=80=99 is used uninitialized in this fu= nction [-Wuninitialized] g =3D *p; ~~^~~~=