This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [RFC][PATCH v9 1/6] Correct the size of _nl_value_type_LC_... arrays.
- From: Zack Weinberg <zackw at panix dot com>
- To: Rafal Luzynski <digitalfreak at lingonborough dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Fri, 27 Oct 2017 11:00:51 -0400
- Subject: Re: [RFC][PATCH v9 1/6] Correct the size of _nl_value_type_LC_... arrays.
- Authentication-results: sourceware.org; auth=none
- References: <291099144.1094665.1505817664806@poczta.nazwa.pl>
On Tue, Sep 19, 2017 at 6:41 AM, Rafal Luzynski
<digitalfreak@lingonborough.com> wrote:
> There were several problems with checking the array size in the past,
> for example BZ#356, caused by incorrectly assuming that every locale
> token represents one element. In fact, if a token represented
> a subarray, for example an array of month names or characters category
> and it appeared at the end of the array the compiler assumed that
> the array ends just after the first element of the subarray.
> Workarounds used in the past was to skip some categories while testing,
> for example LC_CTYPE. Now when we are about to add alternative month
> names to LC_TIME (BZ#10871) this will fail again.
>
...
> #define DEFINE_CATEGORY(category, category_name, items, a) \
> -static const enum value_type _nl_value_type_##category[] = { NO_PAREN items };
> +static const enum value_type _nl_value_type_##category \
> + [_NL_ITEM_INDEX (_NL_NUM_##category)] = { NO_PAREN items };
> #define DEFINE_ELEMENT(element, element_name, optstd, type, rest...) \
> [_NL_ITEM_INDEX (element)] = type,
> #include "categories.def"
Please add a short version of your commit-message explanation of the
change as a comment right above "#define DEFINE_CATEGORY". Something
like
/* The size of the array must be specified explicitly because some of
the 'items' may be
subarrays, which will cause the compiler to deduce an incorrect
size from the initializer. */
OK with that change; as this is independent of the rest of the
patches, please go ahead and push it immediately, without the rest of
them.
zw