NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/58319: usr.bin/mklocale/Makefile misdefines NBCHAR_MAX



>Number:         58319
>Category:       lib
>Synopsis:       usr.bin/mklocale/Makefile misdefines NBCHAR_MAX
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 07 08:10:00 +0000 2024
>Originator:     Collin Funk
>Release:        NetBSD 10.0 and earlier
>Organization:
GNU
>Environment:
N/A
>Description:
Hello,

I was looking into a GNU findutils bug report that reported a Gnulib test failure [1]. The issue was that values set in the return value of localeconv() are not equal to CHAR_MAX on RISC-V where the 'char' type is unsigned. POSIX 2018 states [2]:

The members with type char are non-negative numbers, any of which can be {CHAR_MAX} to indicate that the value is not available in the current locale.

I am waiting for the reporter to respond with what platform they encountered this on, so I am not sure if this specific bug is on NetBSD. However, looking into the localeconv() on various platforms I found an incorrect definition in a Makefile.

In src/usr.bin/mklocale/Makefile line 18 CPPFLAGS has '-DNBCHAR_MAX=127'. I am not familiar with BSD Make but it seems this value is used to set the C locale localeconv cache in src/lib/libc/locale/global_locale.c line 127 - 140. In line 46 - 48:

#ifndef NBCHAR_MAX
#define NBCHAR_MAX (char)CHAR_MAX
#endif

This value is correct since on platforms where char is unsigned it will be 255 and not 127. If that Makefile defines NBCHAR_MAX when compiling libc then the value will be incorrect. Let me know if that explanation makes sense. I'm hoping that someone more familar with NetBSD's build system can help.


[1] https://lists.gnu.org/archive/html/bug-findutils/2024-06/msg00036.html
[2] https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/
>How-To-Repeat:
If someone has access to a NetBSD machine where 'char' is unsigned the following test will be helpful:

   $ git clone --depth=1 https://git.savannah.gnu.org/git/gnulib.git
   $ cd gnulib
   $ ./gnulib-tool --create-testdir --single-configure --dir testdir1 localeconv
   $ cd testdir1
   $ ./configure
   $ make check

If you see:

   FAIL: test-localeconv

then the definition is probably incorrect.

I'll update once I hear from the bug report. However, I think that definition is incorrect anyways so I figured it was worth reporting.
>Fix:
I don't think the value defined in that Makefile is necessary. If possible, I would just trust CHAR_MAX.



Home | Main Index | Thread Index | Old Index