diff options
author | Florian Weimer <fweimer@redhat.com> | 2019-09-03 14:01:39 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2019-09-03 14:01:47 +0200 |
commit | 1471fa556afb428c4a4c46cf5543a4101d5bcf91 (patch) | |
tree | f74fdb5a42fb30bd7b7b56ae4c7bca3091489b51 /locale/programs/ld-ctype.c | |
parent | 9a1e7257a4292d3aea45c8317df3956f4331d8ce (diff) | |
download | glibc-1471fa556afb428c4a4c46cf5543a4101d5bcf91.tar.gz glibc-1471fa556afb428c4a4c46cf5543a4101d5bcf91.tar.xz glibc-1471fa556afb428c4a4c46cf5543a4101d5bcf91.zip |
localedef: Use initializer for flexible array member [BZ #24950]
struct charseq used a zero-length array instead of a flexible array member. This required a strange construct to initialize struct charseq objects, and GCC 10 warns about that: cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] In file included from programs/repertoire.h:24, from programs/localedef.h:32, from programs/ld-ctype.c:35: programs/charmap.h:63:17: note: destination object declared here 63 | unsigned char bytes[0]; | ^~~~~ cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] programs/charmap.h:63:17: note: destination object declared here cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] programs/charmap.h:63:17: note: destination object declared here cc1: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=] programs/charmap.h:63:17: note: destination object declared here The change makes the object physically const, but it is not expected to be modified.
Diffstat (limited to 'locale/programs/ld-ctype.c')
-rw-r--r-- | locale/programs/ld-ctype.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c index cfc9c43fd5..9123f64a56 100644 --- a/locale/programs/ld-ctype.c +++ b/locale/programs/ld-ctype.c @@ -842,8 +842,6 @@ no input digits defined and none of the standard names in the charmap")); for (cnt = 0; cnt < 10; ++cnt) if (ctype->mboutdigits[cnt] == NULL) { - static struct charseq replace[2]; - if (!warned) { record_error (0, 0, _("\ @@ -851,10 +849,12 @@ not all characters used in `outdigit' are available in the charmap")); warned = 1; } - replace[0].nbytes = 1; - replace[0].bytes[0] = '?'; - replace[0].bytes[1] = '\0'; - ctype->mboutdigits[cnt] = &replace[0]; + static const struct charseq replace = + { + .nbytes = 1, + .bytes = "?", + }; + ctype->mboutdigits[cnt] = (struct charseq *) &replace; } warned = 0; |