From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 767FC388C03A; Mon, 2 Aug 2021 19:57:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 767FC388C03A From: "msebor at gmail dot com" To: glibc-bugs-regex@sourceware.org Subject: [Bug regex/28170] New: attribute access (write_only, 4, 3) on regexec triggers a warning Date: Mon, 02 Aug 2021 19:57:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: regex X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot 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 cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: glibc-bugs-regex@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-bugs-regex mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Aug 2021 19:57:06 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D28170 Bug ID: 28170 Summary: attribute access (write_only, 4, 3) on regexec triggers a warning Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: regex Assignee: unassigned at sourceware dot org Reporter: msebor at gmail dot com CC: drepper.fsp at gmail dot com Target Milestone: --- Commit 26492c0a14966c32c43cd6ca1d0dca5e62c6cfef (https://sourceware.org/pipermail/glibc-cvs/2021q2/073049.html) adds attrib= ute access to a number of APIs, including the regexec function like so: @@ -648,10 +655,12 @@ extern int regcomp (regex_t *_Restrict_ __preg, extern int regexec (const regex_t *_Restrict_ __preg, const char *_Restrict_ __String, size_t __nmatch, regmatch_t __pmatch[_Restrict_arr_], - int __eflags); + int __eflags) + __attr_access ((__write_only__, 4, 3)); The attribute was added here based on the POSIX description of the function that describes the pmatch array referenced by it as write-only (at least nothing I can find in POSIX says the function writes to it). With a recent GCC 12 enhancement to detect read accesses to write-only obje= cts the presence of the attribute triggers the following warning: regexec.c: In function =E2=80=98__regexec=E2=80=99: regexec.c:204:13: warning: =E2=80=98*pmatch.rm_so=E2=80=99 is used uninitia= lized [-Wuninitialized] regexec.c:192:101: note: accessing argument 4 of a function declared with attribute =E2=80=98access (write_only, 4, 3)=E2=80=99 The warning indicates that the attribute may not, in fact, appropriate for = the function when since it writes to the referenced object. The write takes pl= ace when the REG_STARTEND bit (a Glibc extension) is set in flags. --=20 You are receiving this mail because: You are on the CC list for the bug.=