From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6167D384780E; Sun, 18 Jul 2021 02:08:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6167D384780E From: "eggert at cs dot ucla.edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101494] New: -Wmaybe-uninitialized false alarm with memrchr of size 0 Date: Sun, 18 Jul 2021 02:08:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.1.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: eggert at cs dot ucla.edu 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: Sun, 18 Jul 2021 02:08:48 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101494 Bug ID: 101494 Summary: -Wmaybe-uninitialized false alarm with memrchr of size 0 Product: gcc Version: 11.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: eggert at cs dot ucla.edu Target Milestone: --- I ran into this problem when compiling Gnulib tests on gcc (GCC) 11.1.1 20210531 (Red Hat 11.1.1-3) on x86-64. Here is a stripped down program illustrating the bug: void *malloc (unsigned long) __attribute__((__malloc__)) __attribute__((__alloc_size__ (1))); void *memrchr (const void *, int, unsigned long) __attribute__((__access__ (__read_only__, 1, 3))); int main (void) { char *input =3D malloc (1); if (!input) return 1; *input =3D 0; return !!memrchr (input, 'a', 0); } The following command: gcc -Wmaybe-uninitialized -O2 -S w.i outputs: w.i: In function 'main': w.i:14:12: warning: 'input' may be used uninitialized [-Wmaybe-uninitialize= d] 14 | return !!memrchr (input, 'a', 0); | ^~~~~~~~~~~~~~~~~~~~~~~ w.i:4:7: note: in a call to 'memrchr' declared with attribute 'access (read_onl\ y, 1, 3)' here 4 | void *memrchr (const void *, int, unsigned long) | ^~~~~~~ This warning is bogus, as 'input' is initialized; and even if "input =3D 0;= " were removed the call to memrchr would still be valid as the size argument is 0.=