Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 1 | From cbada1a1b218c1ef61d0eb4363fad7598e6509d6 Mon Sep 17 00:00:00 2001 |
| 2 | From: Martin Jansa <Martin.Jansa@gmail.com> |
| 3 | Date: Sun, 30 Sep 2018 09:16:48 +0000 |
| 4 | Subject: [PATCH] locale: prevent maybe-uninitialized errors with -Os [BZ |
| 5 | #19444] |
| 6 | |
| 7 | Fixes following error when building for aarch64 with -Os: |
| 8 | | In file included from strcoll_l.c:43: |
| 9 | | strcoll_l.c: In function '__strcoll_l': |
| 10 | | ../locale/weight.h:31:26: error: 'seq2.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] |
| 11 | | int_fast32_t i = table[*(*cpp)++]; |
| 12 | | ^~~~~~~~~ |
| 13 | | strcoll_l.c:304:18: note: 'seq2.back_us' was declared here |
| 14 | | coll_seq seq1, seq2; |
| 15 | | ^~~~ |
| 16 | | In file included from strcoll_l.c:43: |
| 17 | | ../locale/weight.h:31:26: error: 'seq1.back_us' may be used uninitialized in this function [-Werror=maybe-uninitialized] |
| 18 | | int_fast32_t i = table[*(*cpp)++]; |
| 19 | | ^~~~~~~~~ |
| 20 | | strcoll_l.c:304:12: note: 'seq1.back_us' was declared here |
| 21 | | coll_seq seq1, seq2; |
| 22 | | ^~~~ |
| 23 | |
| 24 | Partial fix for [BZ #23716] |
| 25 | * locale/weight.h: Fix build with -Os. |
| 26 | |
| 27 | Work around the issue instead of removing -O like we do with |
| 28 | SELECTED_OPTIMIZATION |
| 29 | |
| 30 | Upstream-Status: Submitted [https://www.sourceware.org/ml/libc-alpha/2018-09/msg00539.html] |
| 31 | |
| 32 | Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> |
| 33 | --- |
| 34 | ChangeLog | 4 ++++ |
| 35 | locale/weight.h | 7 +++++++ |
| 36 | 2 files changed, 11 insertions(+) |
| 37 | |
| 38 | diff --git a/ChangeLog b/ChangeLog |
| 39 | index 216336edc9..84fbbf47ed 100644 |
| 40 | --- a/ChangeLog |
| 41 | +++ b/ChangeLog |
| 42 | @@ -1,3 +1,7 @@ |
| 43 | +2018-09-30 Martin Jansa <Martin.Jansa@gmail.com> |
| 44 | + Partial fix for [BZ #23716] |
| 45 | + * locale/weight.h: Fix build with -Os. |
| 46 | + |
| 47 | 2018-09-30 Martin Jansa <Martin.Jansa@gmail.com> |
| 48 | Partial fix for [BZ #23716] |
| 49 | * sysdeps/ieee754/soft-fp/s_fdiv.c: Fix build with -O. |
| 50 | diff --git a/locale/weight.h b/locale/weight.h |
| 51 | index 6028d3595e..10bcea25e5 100644 |
| 52 | --- a/locale/weight.h |
| 53 | +++ b/locale/weight.h |
| 54 | @@ -28,7 +28,14 @@ findidx (const int32_t *table, |
| 55 | const unsigned char *extra, |
| 56 | const unsigned char **cpp, size_t len) |
| 57 | { |
| 58 | + /* With GCC 8 when compiling with -Os the compiler warns that |
| 59 | + seq1.back_us and seq2.back_us might be used uninitialized. |
| 60 | + This uninitialized use is impossible for the same reason |
| 61 | + as described in comments in locale/weightwc.h. */ |
| 62 | + DIAG_PUSH_NEEDS_COMMENT; |
| 63 | + DIAG_IGNORE_Os_NEEDS_COMMENT (8, "-Wmaybe-uninitialized"); |
| 64 | int_fast32_t i = table[*(*cpp)++]; |
| 65 | + DIAG_POP_NEEDS_COMMENT; |
| 66 | const unsigned char *cp; |
| 67 | const unsigned char *usrc; |
| 68 | |