From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 86CE83858437; Wed, 5 Oct 2022 21:43:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 86CE83858437 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665006209; bh=NerAtNgWbqfrL4MdJa+OzdAod44h9FQfpgTi20AntW4=; h=From:To:Subject:Date:From; b=LPTT5bfH9CUoTRqGvAyh8uSoaklEs8p7iP9AS1beGmAqxDCYlPjN5YI3qk3LufY33 7h8to9i68ei8z1Gy2XyrfYKs5NPcngGO5Qpi/tZ/puZnUE5DUynskB3dWnWDA5bnjS kyVHir5SpzY956cXxWB2IkQQo+41Wdli8+wyndlY= 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] locale: prevent maybe-uninitialized errors with -Os [BZ #19444] X-Act-Checkin: glibc X-Git-Author: Martin Jansa X-Git-Refname: refs/heads/master X-Git-Oldrev: a878a1384c8f7ae2383c4413feab88ba2fee7f17 X-Git-Newrev: c651f9da530320e9939e6cbad57b87695eeba41c Message-Id: <20221005214329.86CE83858437@sourceware.org> Date: Wed, 5 Oct 2022 21:43:29 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=c651f9da530320e9939e6cbad57b87695eeba41c commit c651f9da530320e9939e6cbad57b87695eeba41c 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 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;