public inbox for glibc-bugs-regex@sourceware.org
help / color / mirror / Atom feed
From: "msebor at gmail dot com" <sourceware-bugzilla@sourceware.org>
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	[thread overview]
Message-ID: <bug-28170-132@http.sourceware.org/bugzilla/> (raw)

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.

             reply	other threads:[~2021-08-02 19:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 19:57 msebor at gmail dot com [this message]
2021-08-13 21:54 ` [Bug regex/28170] " msebor at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28170-132@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs-regex@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).