From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1D88D3858421; Tue, 11 Jul 2023 19:02:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D88D3858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689102163; bh=rEqJ9JgJyEbB6xE+OPjuIH+8rJ+3KurF0H9Ln4zm17o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ek6vd8bDTlkDgw/PJVI6mpcRqmcEuICxwM4YPUZTw8VwHrbNHUwnPRHXL471TY1qR 6i0me6Xm+YZ4x6IX2iCZhopoAN1cyitMvLprNh1DGgOIwDTxuaFQAu8Tr3LuDEeyKJ a9ryaTrkjVgLi/ZBPcT6Y80S1KpoTAyaWw9LNVyY= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/99945] missing maybe-uninitialized warning when using nested function vs SRA Date: Tue, 11 Jul 2023 19:02:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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=3D99945 --- Comment #7 from Andrew Pinski --- This has nothing to do with cleanup functions but just nested functions vs = SRA. Take: ``` int foo1 (void); int foo2 (int); #ifdef D #define N #else #define N ! #endif int bar (void) { int i; auto void cf (int *t) { foo2 (i); } int t; t =3D 0; if (foo1 ()) i =3D foo1 (); i =3D N foo1 () || i; foo2 (i); cf(&t); return 0; } ``` Which is the same as the original one without the cleanup attribute (basica= lly added the call to cf). Using `-O2 -Wall -DD -fno-tree-sra` causes the following warning the be do= ne: ``` : In function 'bar': :22:17: warning: 'FRAME.1.i' may be used uninitialized [-Wmaybe-uninitialized] 22 | i =3D N foo1 () || i; | ~~~~~~~~^~~~ :11:5: note: 'FRAME.1' declared here 11 | int bar (void) | ^~~ ``` Without `-fno-tree-sra`, there is no warning because SRA produces: ``` # SR.4_14 =3D PHI _2 =3D foo1 (); _17 =3D _2 | SR.4_14; ``` which should 100% warn but since SR.4 is artifical does not.=