Hi,
Grisha Levit wrote:
> On macOS with GCC I get:
>
> lib/localename-unsafe.c: In function 'gl_locale_name_canonicalize':
> lib/localename-unsafe.c:1345:7: warning: initializer-string for array of
> 'char' truncates NUL terminator but destination lacks 'nonstring' attribute
> (9 chars into 8 available) [-Wunterminated-string-initialization]
> 1345 | { "yue-Hans", "yue" },
> | ^~~~~~~~~~
>
> This seems like a correct warning based on the struct definition:
>
> typedef struct { const char langtag[7+1]; const char unixy[12+1]; }
> langtag_entry;
>
> and "yue-Hans" being one char longer than all the other langtags.
Indeed. Thanks for the report. Fixed like this:
2025-10-03 Bruno Haible <[email protected]>
localename-unsafe: Fix handling of yue-Hans locale on macOS.
Reported by Grisha Levit <[email protected]> in
<https://lists.gnu.org/archive/html/bug-gnulib/2025-10/msg00002.html>.
* lib/localename-unsafe.c (langtag_entry): Adjust array dimensions of
elements.
diff --git a/lib/localename-unsafe.c b/lib/localename-unsafe.c
index 708aa28569..08db8585cd 100644
--- a/lib/localename-unsafe.c
+++ b/lib/localename-unsafe.c
@@ -1299,7 +1299,7 @@ gl_locale_name_canonicalize (char *name)
/* Convert new-style locale names with language tags (ISO 639 and ISO 15924)
to Unix (ISO 639 and ISO 3166) names. */
- typedef struct { const char langtag[7+1]; const char unixy[12+1]; }
+ typedef struct { const char langtag[8+1]; const char unixy[5+1]; }
langtag_entry;
static const langtag_entry langtag_table[] = {
/* Mac OS X has "az-Arab", "az-Cyrl", "az-Latn".