From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 49CC6384843F; Wed, 21 Jul 2021 18:05:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 49CC6384843F From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101494] -Wmaybe-uninitialized false alarm with memrchr of size 0 Date: Wed, 21 Jul 2021 18:05:30 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor 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: cf_reconfirmed_on bug_status cc everconfirmed 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 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: Wed, 21 Jul 2021 18:05:30 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101494 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2021-07-21 Status|UNCONFIRMED |NEW CC| |msebor at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #2 from Martin Sebor --- Confirmed. I think this exposes two underlying bugs: one that the initialization isn't detected and another that the second argument to attri= bute access isn't respected. A slightly enhanced test case: $ cat b.c && gcc -O2 -S -Wall b.c __attribute__ ((access (read_only, 1, 2))) void f (const void*, int); void g (void) { char *p =3D __builtin_alloca (1); *p =3D 0; f (p, 0); // bogus -Wmaybe-uninitialized } void h (void) { char *p =3D __builtin_malloc (1); f (p, 0); // bogus -Wmaybe-uninitialized } b.c: In function =E2=80=98g=E2=80=99: b.c:7:3: warning: =E2=80=98p=E2=80=99 is used uninitialized [-Wuninitialize= d] 7 | f (p, 0); // bogus -Wmaybe-uninitialized | ^~~~~~~~ b.c:1:49: note: in a call to =E2=80=98f=E2=80=99 declared with attribute = =E2=80=98access (read_only, 1, 2)=E2=80=99 here 1 | __attribute__ ((access (read_only, 1, 2))) void f (const void*, int= ); | ^ b.c: In function =E2=80=98h=E2=80=99: b.c:13:3: warning: =E2=80=98p=E2=80=99 is used uninitialized [-Wuninitializ= ed] 13 | f (p, 0); // bogus -Wmaybe-uninitialized | ^~~~~~~~ b.c:1:49: note: in a call to =E2=80=98f=E2=80=99 declared with attribute = =E2=80=98access (read_only, 1, 2)=E2=80=99 here 1 | __attribute__ ((access (read_only, 1, 2))) void f (const void*, int= ); | ^=