public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
* [Bug regex/28170] New: attribute access (write_only, 4, 3) on regexec triggers a warning
@ 2021-08-02 19:57 msebor at gmail dot com
  2021-08-13 21:54 ` [Bug regex/28170] " msebor at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: msebor at gmail dot com @ 2021-08-02 19:57 UTC (permalink / raw)
  To: glibc-bugs-regex

https://sourceware.org/bugzilla/show_bug.cgi?id=28170

            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 attribute
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 objects
the presence of the attribute triggers the following warning:

regexec.c: In function ‘__regexec’:
regexec.c:204:13: warning: ‘*pmatch.rm_so’ is used uninitialized
[-Wuninitialized]
regexec.c:192:101: note: accessing argument 4 of a function declared with
attribute ‘access (write_only, 4, 3)’

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 place
when the REG_STARTEND bit (a Glibc extension) is set in flags.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug regex/28170] attribute access (write_only, 4, 3) on regexec triggers a warning
  2021-08-02 19:57 [Bug regex/28170] New: attribute access (write_only, 4, 3) on regexec triggers a warning msebor at gmail dot com
@ 2021-08-13 21:54 ` msebor at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: msebor at gmail dot com @ 2021-08-13 21:54 UTC (permalink / raw)
  To: glibc-bugs-regex

https://sourceware.org/bugzilla/show_bug.cgi?id=28170

--- Comment #1 from Martin Sebor <msebor at gmail dot com> ---
Patch: https://sourceware.org/pipermail/libc-alpha/2021-August/130137.html

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-13 21:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-02 19:57 [Bug regex/28170] New: attribute access (write_only, 4, 3) on regexec triggers a warning msebor at gmail dot com
2021-08-13 21:54 ` [Bug regex/28170] " msebor at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).