From patchwork Thu Apr 4 19:17:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jansa X-Patchwork-Id: 32168 Received: (qmail 89600 invoked by alias); 4 Apr 2019 19:17:53 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 89592 invoked by uid 89); 4 Apr 2019 19:17:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=prevent X-HELO: mail-wr1-f65.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=GK1nJvGNkj+WGBVtnaKrF3Rb9YE+0lt2G4fTmVw421Q=; b=izRbzTr/jwWyatY7CJfJDpjMmV6C3FpACWaxoJNwSlOs7+SGd04jJPNUAYAdShXZxk 5iJfZQmXOrFLZXwPz9snzPz3YGZLrZDUDHTB4dW+KzZhH848UUoGFOsbEfuAXeZm2zkY qLo1O6k2vVDib0iRJjujQ6dcUl8Zb+KjUzoWPU+VB19hzFuVjmzv5dm2Cy2P9DfoJlhc Cj9iDejaBZ6jTxBVQT7EsjsqEOnz2ODYLZURWmhwpdx7kgTbdmGOZ+XOrE5p+UG3m987 NHyt7q/Sghf+aw3Hp79m8uuZRROYJonJzW+S0n0FEeTW0SD4bZ8SiOkrjHL1TfO4VhFz wcaA== Return-Path: From: Martin Jansa To: libc-alpha@sourceware.org Cc: Martin Jansa Subject: [PATCH] locale: prevent maybe-uninitialized errors with -Os [BZ #19444] Date: Thu, 4 Apr 2019 19:17:48 +0000 Message-Id: <20190404191748.105-1-Martin.Jansa@gmail.com> Fixes following error when building for aarch64 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; | ^~~~ Partial fix for [BZ #19444] * locale/weight.h: Fix build with -Os. Signed-off-by: Martin Jansa --- ChangeLog | 5 +++++ locale/weight.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index b00c783bcc..73db7b5012 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-04-04 Martin Jansa + + Partial fix for [BZ #19444] + * locale/weight.h: Fix build with -Os. + 2019-04-04 Adhemerval Zanella * sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcsrchr.c): diff --git a/locale/weight.h b/locale/weight.h index 7ca81498b2..d608ca70bb 100644 --- a/locale/weight.h +++ b/locale/weight.h @@ -28,7 +28,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"); int_fast32_t i = table[*(*cpp)++]; + DIAG_POP_NEEDS_COMMENT; const unsigned char *cp; const unsigned char *usrc;