public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/release/2.36/master] locale: prevent maybe-uninitialized errors with -Os [BZ #19444]
Date: Thu, 29 Dec 2022 12:53:08 +0000 (GMT)	[thread overview]
Message-ID: <20221229125308.3E9063858D20@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4444be051cae74fed390d4bc1a15ed730cc07b02

commit 4444be051cae74fed390d4bc1a15ed730cc07b02
Author: Martin Jansa <Martin.Jansa@gmail.com>
Date:   Wed Sep 21 10:51:03 2022 -0300

    locale: prevent maybe-uninitialized errors with -Os [BZ #19444]
    
    Fixes following error when building  with -Os:
    | In file included from strcoll_l.c:43:
    | strcoll_l.c: In function '__strcoll_l':
    | ../locale/weight.h:31:26: error: 'seq2.back_us' may be used
    uninitialized in this function [-Werror=maybe-uninitialized]
    |    int_fast32_t i = table[*(*cpp)++];
    |                           ^~~~~~~~~
    | strcoll_l.c:304:18: note: 'seq2.back_us' was declared here
    |    coll_seq seq1, seq2;
    |                   ^~~~
    | In file included from strcoll_l.c:43:
    | ../locale/weight.h:31:26: error: 'seq1.back_us' may be used
    uninitialized in this function [-Werror=maybe-uninitialized]
    |    int_fast32_t i = table[*(*cpp)++];
    |                           ^~~~~~~~~
    | strcoll_l.c:304:12: note: 'seq1.back_us' was declared here
    |    coll_seq seq1, seq2;
    |             ^~~~
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
    Tested-by: Carlos O'Donell <carlos@redhat.com>
    
    (cherry picked from commit c651f9da530320e9939e6cbad57b87695eeba41c)

Diff:
---
 locale/weight.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/locale/weight.h b/locale/weight.h
index 8be2d220f8..4a4d5aa6b2 100644
--- a/locale/weight.h
+++ b/locale/weight.h
@@ -27,7 +27,14 @@ findidx (const int32_t *table,
 	 const unsigned char *extra,
 	 const unsigned char **cpp, size_t len)
 {
+  /* With GCC 8 when compiling with -Os the compiler warns that
+     seq1.back_us and seq2.back_us might be used uninitialized.
+     This uninitialized use is impossible for the same reason
+     as described in comments in locale/weightwc.h.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized");
   int32_t i = table[*(*cpp)++];
+  DIAG_POP_NEEDS_COMMENT;
   const unsigned char *cp;
   const unsigned char *usrc;

                 reply	other threads:[~2022-12-29 12:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221229125308.3E9063858D20@sourceware.org \
    --to=azanella@sourceware.org \
    --cc=glibc-cvs@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).