From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 3E9063858D20; Thu, 29 Dec 2022 12:53:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E9063858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1672318388; bh=/r4ouYwLkl7vy5VBq4UAzvlWII9iA0pwyHEmKNER6lw=; h=From:To:Subject:Date:From; b=cy7IbSNrIaAAv8bEaWqT7bpf1BuP+B7QRB+H/Mm3aj7aa50OiBjj1JoOa25TrFPeX +yBOGNlrZg2u8rAvODeMcZ0i+A0SHueZ43K4nCSocf7lvUuWkGZM6VnoGRmC/BDzq0 euDLP46wzt87Jsdj3WeK05bBqaOPp8ihLJTrsvPg= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/release/2.36/master] locale: prevent maybe-uninitialized errors with -Os [BZ #19444] X-Act-Checkin: glibc X-Git-Author: Martin Jansa X-Git-Refname: refs/heads/release/2.36/master X-Git-Oldrev: 4321cbc2af788827e56e5581f56d7da2876b48f1 X-Git-Newrev: 4444be051cae74fed390d4bc1a15ed730cc07b02 Message-Id: <20221229125308.3E9063858D20@sourceware.org> Date: Thu, 29 Dec 2022 12:53:08 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4444be051cae74fed390d4bc1a15ed730cc07b02 commit 4444be051cae74fed390d4bc1a15ed730cc07b02 Author: Martin Jansa 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 Tested-by: Carlos O'Donell (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;