1 From 6fea0a8e33760258c4baa5d0a6f3a145897427fe Mon Sep 17 00:00:00 2001
2 From: Florian Weimer <fweimer@redhat.com>
3 Date: Tue, 3 Sep 2019 14:01:39 +0200
4 Subject: [PATCH] localedef: Use initializer for flexible array member [BZ
7 struct charseq used a zero-length array instead of a flexible array
8 member. This required a strange construct to initialize struct
9 charseq objects, and GCC 10 warns about that:
11 cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
12 In file included from programs/repertoire.h:24,
13 from programs/localedef.h:32,
14 from programs/ld-ctype.c:35:
15 programs/charmap.h:63:17: note: destination object declared here
16 63 | unsigned char bytes[0];
18 cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
19 programs/charmap.h:63:17: note: destination object declared here
20 cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
21 programs/charmap.h:63:17: note: destination object declared here
22 cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
23 programs/charmap.h:63:17: note: destination object declared here
25 The change makes the object physically const, but it is not expected
28 [Upstream: https://sourceware.org/git/?p=glibc.git;a=patch;h=1471fa556afb428c4a4c46cf5543a4101d5bcf91]
29 [Dropped confliciting ChangeLog part]
30 Signed-off-by: Peter Seiderer <ps.report@gmx.net>
32 locale/programs/charmap.h | 2 +-
33 locale/programs/ld-ctype.c | 12 ++++++------
34 2 files changed, 7 insertions(+), 7 deletions(-)
36 diff --git a/locale/programs/charmap.h b/locale/programs/charmap.h
37 index 870a9e95..70db330d 100644
38 --- a/locale/programs/charmap.h
39 +++ b/locale/programs/charmap.h
40 @@ -60,7 +60,7 @@ struct charseq
44 - unsigned char bytes[0];
45 + unsigned char bytes[];
49 diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
50 index cfc9c43f..9123f64a 100644
51 --- a/locale/programs/ld-ctype.c
52 +++ b/locale/programs/ld-ctype.c
53 @@ -842,8 +842,6 @@ no input digits defined and none of the standard names in the charmap"));
54 for (cnt = 0; cnt < 10; ++cnt)
55 if (ctype->mboutdigits[cnt] == NULL)
57 - static struct charseq replace[2];
61 record_error (0, 0, _("\
62 @@ -851,10 +849,12 @@ not all characters used in `outdigit' are available in the charmap"));
66 - replace[0].nbytes = 1;
67 - replace[0].bytes[0] = '?';
68 - replace[0].bytes[1] = '\0';
69 - ctype->mboutdigits[cnt] = &replace[0];
70 + static const struct charseq replace =
75 + ctype->mboutdigits[cnt] = (struct charseq *) &replace;