From patchwork Wed Feb 27 22:31:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jansa X-Patchwork-Id: 31677 Received: (qmail 58197 invoked by alias); 27 Feb 2019 22:32:00 -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 58185 invoked by uid 89); 27 Feb 2019 22:32:00 -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, TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=HX-Envelope-From:sk:martin., Partial X-HELO: mail-wm1-f68.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=aCPJ/b0+DAhK1pRxf5hCkq23X3sVhciUsPCwa6phwhM=; b=EJjhNqku5Ju+C8irbmpIcbMfvefXUCGQ73XfcDdXo9w9hWeIdwCxDuAqeGuzsXOHTV nzGhz9E1j3EVk0QRolaLbLaLAHbtI98yUfVQusZAFSxsYvoWiTzU2Me730+GSDMfiqqF rN98YHl6BrTZkMSjFnYE9R8H0Jrwa9e9mH0LVlbYQa1rehhMuzVrXe5nE0SikZlMv3fV 5GsOGHyu1u+m7I7/d3MtBQB3YqRmtgFqLrC0jC56kmHiSr3EPkjFIL+m/iuYqUl3OF81 neriZATyvakf2HjsjtPqksxoHuQ3ujavVCne2Kezpf+1s/DR6yEKI7ZfEy9iXpLAA1FE i7Vw== 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: Wed, 27 Feb 2019 22:31:40 +0000 Message-Id: <20190227223140.25379-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 ed05044fe8..f08196da7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2019-02-28 Martin Jansa + + Partial fix for [BZ #19444] + * locale/weight.h: Fix build with -Os. + 2019-02-27 H.J. Lu * configure.ac (have-ifunc): New LIBC_CONFIG_VAR. 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;