Paul Eggert [Sat, 9 May 2026 05:57:46 +0000 (22:57 -0700)]
u64: go back to casts for u64init
* lib/u64.h (u64init) [INT_MAX < UINT64_MAX]: Don’t use a compound
literal here, as u64init is intended for use in static
initializers. Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2026-05/msg00063.html
Paul Eggert [Fri, 8 May 2026 22:35:18 +0000 (15:35 -0700)]
Avoid string literal type confusion
Instead of ‘... (char *) "abc" ...’, which is a bit confusing as
"abc" is already of type char *, use ‘static char const s[] =
"abc"; ... (char *) s .... This pacifices -Wuseless-cast.
* lib/boot-time.c (get_boot_time_uncached):
* lib/time_rz.c (save_abbr):
* tests/test-posix_spawn-chdir.c (test):
* tests/test-posix_spawn-fchdir.c (test):
* tests/test-unsetenv.c (main):
Redo with named string as described above.
Paul Eggert [Fri, 8 May 2026 22:17:06 +0000 (15:17 -0700)]
times-tests: pacify -Wuseless-cast
* tests/test-times.c (tms2ms): New function.
(main): Use it to simplify printing and avoid need for casts.
Pacify -Wuseless-cast via compound literals.
Paul Eggert [Fri, 8 May 2026 22:15:31 +0000 (15:15 -0700)]
strncat-tests: omit confusing casts
* tests/test-strncpy.c (check): Omit no-op cast.
* tests/unistr/test-strncat.h (check): Use better type for
page_boundary, removing the need for a cast.
Paul Eggert [Fri, 8 May 2026 21:28:51 +0000 (14:28 -0700)]
Avoid useless casts in m4/*.m4.
This is mostly for consistency. In theory it could help
if someone mistakenly configures with -Wuseless-cast in CFLAGS.
* m4/c32rtomb.m4 (gl_C32RTOMB_SANITYCHECK):
* m4/iswdigit.m4 (gl_FUNC_ISWDIGIT):
* m4/iswxdigit.m4 (gl_FUNC_ISWXDIGIT):
* m4/mbrtoc32.m4 (gl_MBRTOC32_SANITYCHECK):
* m4/mbrtowc.m4 (gl_MBRTOWC_NULL_ARG1)
(gl_MBRTOWC_STORES_INCOMPLETE):
* m4/mbsnrtowcs.m4 (gl_MBSNRTOWCS_WORKS_IN_TRADITIONAL_LOCALE):
* m4/wcrtomb.m4 (gl_FUNC_WCRTOMB):
Do not cast to wchar_t when the context is already wchar_t.
Paul Eggert [Fri, 8 May 2026 21:22:56 +0000 (14:22 -0700)]
Suppress -Wuseless-cast when calling mmap
I assume the void * casts for mmap are for ancient systems
where mmap returned char *, though Gnulib no longer ports to those.
For now, simply suppress the warning in the few places that use
mmap directly.
* lib/stackvma.c, lib/vma-iter.c, tests/mmap-anon-util.h:
Ignore -Wuseless-cast.
Paul Eggert [Fri, 8 May 2026 21:19:03 +0000 (14:19 -0700)]
sigsegv: pacify -Wuseless-cast
This also makes the code a bit less confusing.
* lib/sigsegv.c (SIGSEGV_FAULT_ADDRESS): Now of type void *.
Change the Hurd implementation to guarantee this.
(sigsegv_handler): Omit no-longer needed cast to void *.
Omit function pointer cast when SIGSEGV_FAULT_ADDRESS_FROM_SIGINFO,
as it’s not needed in that case.
Paul Eggert [Fri, 8 May 2026 20:07:19 +0000 (13:07 -0700)]
md2: omit confusing casts
* lib/md2.c (md2_process_bytes):
Use size_t, not unsigned long, for size.
Although the code was correct it was unclear.
(md2_update_chksum, md2_compress): Omit confusing casts.
Paul Eggert [Fri, 8 May 2026 19:54:37 +0000 (12:54 -0700)]
Pacify -Wuseless-cast for pthread_self
* lib/glthread/thread.h (gl_thread_self_pointer):
* tests/test-pthread-mutex.c, tests/test-pthread-once2.c:
* tests/test-pthread-rwlock.c, tests/test-pthread-spin.c:
* tests/test-pthread-tss.c: Be consistent about casting
pthread_self to void *, by always casting via intptr_t first.
This pacifies -Wuseless-cast on GNU/Linux.
Bruno Haible [Fri, 8 May 2026 07:38:15 +0000 (09:38 +0200)]
Revisit some -Wuseless-cast changes.
* lib/obstack.in.h (obstack_free): Restore parentheses around macro
argument.
* lib/printf-args.c (PRINTF_FETCHARGS): Do use wchar_t-typed constants.
* lib/vma-iter.c (rof_open): Revert last change. Warning now silenced
through gl_CC_GNULIB_WARNINGS.
Paul Eggert [Fri, 8 May 2026 00:07:43 +0000 (17:07 -0700)]
fts: pacify GCC 16 -Wfree-labels
Evidently those FALLTHROUGHs were put in to pacify an old
version of GCC, but that’s no longer needed and nowadays
is even counterproductive.
* lib/fts.c (FALLTHROUGH): Remove; no longer used.
(leaf_optimization): Remove the FALLTHROUGHs.
* modules/fts (Depends-on): Remove ‘attribute’.
Paul Eggert [Fri, 8 May 2026 00:03:53 +0000 (17:03 -0700)]
maint: pacify -Wuseless-cast via compound literals
* lib/fsusage.c (PROPAGATE_ALL_ONES):
* lib/fts-cycle.c (AD_hash):
* lib/hash.c (hash_print_statistics, hash_print):
* lib/malloca.h (nmalloca):
* lib/readutmp.c (add_utmp):
* lib/xsize.h (xtimes):
When ((t) (E)) might provoke a -Wuseless-cast diagnostic in GCC 16,
use ((t) {E}) when that’s easy, i.e., when the expression is not
intended for use as a constant expression.
Paul Eggert [Thu, 7 May 2026 18:25:37 +0000 (11:25 -0700)]
regex-tests: work with wchar-single
* tests/test-regex-el.c, tests/test-regex-en.c, tests/test-regex-tr.c:
New files, containing the locale-specific parts of the old
tests/test-regex.c.
* modules/regex-tests (Files): Add them. Add m4/locale-en.m4.
(configure.ac): Add gt_LOCALE_EN_UTF8.
(TESTS, check_PROGRAMS):
Add test-regex-el, test-regex-en, test-regex-tr.
(TESTS_ENVIRONMENT, test_regex_el_LDADD, test_regex_en_LDADD)
(test_regex_tr_LDADD): New macros.
* tests/test-regex.c: Do not include <locale.h>, <wctype.h>,
"localcharset.h".
(really_utf8): Remove.
(main): Remove the parts assuming specific locales;
they are now moved to the abovementioned new files.
Bruno Haible [Wed, 6 May 2026 18:20:46 +0000 (20:20 +0200)]
stdckdint-h, stdcountof-h, uchar-h: Simplify for when C++ is not used.
Reported by Pádraig Brady in
<https://lists.gnu.org/archive/html/bug-gnulib/2026-05/msg00032.html>.
* m4/stdckdint_h.m4 (gl_STDCKDINT_H): When $CXX is empty, don't run C++
specific tests.
* m4/stdcountof_h.m4 (gl_STDCOUNTOF_H): Likewise.
* m4/uchar_h.m4 (gl_UCHAR_H): Likewise.
Paul Eggert [Wed, 6 May 2026 17:18:48 +0000 (10:18 -0700)]
regex-tests: minor memory cleanup
* tests/test-regex.c (main): No need for regex to be static,
and making it auto is more likely to catch memory leaks in
debugging platforms. Clean up after its last use.
Omit unnecessary setting/freeing of regs that doesn’t test anything.
Paul Eggert [Wed, 6 May 2026 01:11:07 +0000 (18:11 -0700)]
regex: fix glibc bug 20381
* lib/regcomp.c [!_LIBC]: Include localeinfo.h.
(re_set_fastmap): Remove icase arg, since it was not right
for initial bytes in multibyte locales. Change ch arg to
be unsigned char so that callers need not cast. All callers changed.
(re_set_fastmap_icase): New function.
(re_compile_fastmap_iter): Use it.
* modules/regex (Depends-on): Add localeinfo.
* tests/test-regex.c (main): Test for the bug.
Paul Eggert [Wed, 6 May 2026 01:11:07 +0000 (18:11 -0700)]
localeinfo: port to single-byte non-__STDC_ISO_10646__
* lib/localeinfo.c (CHAR32_T_IS_UNICODE): New macro.
(case_folded_counterparts): In single-byte locales where
char32_t is not known to be Unicode, check all 255 possibilities
instead of hoping that char32_t is Unicode.
* lib/localeinfo.h (CASE_FOLDED_BUFSIZE): Increase to 255.
* modules/localeinfo (Depends-on): Add btoc32.
Paul Eggert [Wed, 6 May 2026 01:11:07 +0000 (18:11 -0700)]
localeinfo: add U+1C80 through U+1C88
* lib/localeinfo.c (lonesome_lower): Add U+1C80 through U+1C88,
which all have this property in Unicode 17.0.0. For example,
U+1C80 CYRILLIC SMALL LETTER ROUNDED VE upcases to U+0412 CYRILLIC
CAPITAL LETTER VE which in turn downcases to U+0432 CYRILLIC SMALL
LETTER VE.
Paul Eggert [Wed, 6 May 2026 01:21:54 +0000 (18:21 -0700)]
localeinfo: new module
This is so regex can use localeinfo.[ch].
* modules/dfa (Files): Remove lib/localeinfo.c, lib/localeinfo.h.
(Depends-on): Remove c32tolower, c32toupper. Add localeinfo.
(Include): Remove localeinfo.h.
* modules/localeinfo: New file.
Paul Eggert [Mon, 4 May 2026 21:07:12 +0000 (14:07 -0700)]
Pacify GCC 16 -Wkeyword-macro for ‘restrict’
Problem reported by Collin Funk in:
https://lists.gnu.org/r/bug-gnulib/2026-05/msg00011.html
* m4/gnulib-common.m4 (AC_C_RESTRICT): Sync from Autoconf Savannah
git commit b692310133c217edd7cbeeb1ddf592a18dab945f, and override
for Autoconf 2.73 and earlier. This protects the "#undef
restrict", which may transmute into "#define restrict
__restrict__", if ! (defined __STDC_VERSION__ && 199901L <=
__STDC_VERSION__).
Bruno Haible [Sun, 3 May 2026 13:30:59 +0000 (15:30 +0200)]
acl-permissions: Use the counted_by attribute.
* lib/acl-internal.h (struct permission_context): On Solaris, mark the
entries field as counted_by count and the ace_entries field as
counted_by ace_count.
Bruno Haible [Sun, 3 May 2026 13:05:21 +0000 (15:05 +0200)]
ssfmalloc: Use the counted_by attribute.
* lib/ssfmalloc.h (struct medium_page_header): Mark the gaps field as
counted_by num_gaps.
(allocate_medium_block_in_page): Increase pageptr->num_gaps before
writing into pageptr->gaps.
Bruno Haible [Sun, 3 May 2026 12:27:16 +0000 (14:27 +0200)]
hash: Use the counted_by attribute.
* lib/hash.c (struct hash_table): Mark the bucket field as counted_by
n_buckets. Swap these fields (needed for clang, see
<https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).
Bruno Haible [Sun, 3 May 2026 11:54:51 +0000 (13:54 +0200)]
array-set: Use the counted_by attribute.
* lib/gl_array_set.c (struct gl_set_impl): Mark the elements field as
counted_by count. Swap these fields (needed for clang).
(gl_array_nx_add): Increase set->count before writing into
set->elements.
Bruno Haible [Sun, 3 May 2026 11:53:34 +0000 (13:53 +0200)]
array-oset: Use the counted_by attribute.
* lib/gl_array_oset.c (struct gl_oset_impl): Mark the elements field as
counted_by count. Swap these fields (needed for clang).
(gl_array_nx_add_at): Increase set->count before writing into
set->elements.
Bruno Haible [Sun, 3 May 2026 11:52:05 +0000 (13:52 +0200)]
array-omap: Use the counted_by attribute.
* lib/gl_array_omap.c (struct gl_omap_impl): Mark the pairs field as
counted_by count. Swap these fields (needed for clang).
(gl_array_nx_add_at): Increase map->count before writing into
map->pairs.
Bruno Haible [Sun, 3 May 2026 11:50:43 +0000 (13:50 +0200)]
array-map: Use the counted_by attribute.
* lib/gl_array_map.c (struct gl_map_impl): Mark the pairs field as
counted_by count. Swap these fields (needed for clang).
(gl_array_nx_getput): Increase map->count before writing into
map->pairs.
Bruno Haible [Sun, 3 May 2026 09:41:31 +0000 (11:41 +0200)]
array-list: Use the counted_by attribute.
* lib/gl_array_list.c (struct gl_list_impl): Mark the elements field as
counted_by count. Swap these fields (needed for clang).
(gl_array_nx_add_first, gl_array_nx_add_last, gl_array_nx_add_before,
gl_array_nx_add_after, gl_array_nx_add_at): Increase list->count before
writing into list->elements.
Bruno Haible [Sun, 3 May 2026 08:52:33 +0000 (10:52 +0200)]
exclude: Use the counted_by attribute.
* lib/exclude.c (struct exclude_pattern): Mark the exclude field as
counted_by exclude_count. Swap these fields (needed for clang, see
<https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).
(new_exclude_segment): Update.
(add_exclude): Increase pat->exclude_count before writing into
pat->exclude.
Bruno Haible [Sun, 3 May 2026 08:40:52 +0000 (10:40 +0200)]
dfa: Use the counted_by attribute.
* lib/dfa.c (struct mb_char_classes): Mark the chars field as counted_by
nchars. Swap these fields (needed for clang, see
<https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).
(parse_bracket_exp): Increase dfa->lex.brack.nchars before writing into
dfa->lex.brack.chars.
Bruno Haible [Sun, 3 May 2026 06:51:08 +0000 (08:51 +0200)]
argp: Use the counted_by attribute.
* lib/argp-help.c (struct hol): Mark the entries fields as counted_by
num_entries. Swap these fields (needed for clang, see
<https://discourse.llvm.org/t/rfc-forward-referencing-a-struct-member-within-bounds-annotations/85510>).
Bruno Haible [Fri, 1 May 2026 20:35:13 +0000 (22:35 +0200)]
Improve comments about GCC bugs.
* m4/nullptr.m4 (gl_NULLPTR): Add info about gcc bug 114780.
* modules/uniname/uniname (Makefile.am): Add info about gcc bug 110112.
* tests/test-intprops.c: Correct info about gcc bug 68971.
Paul Eggert [Fri, 1 May 2026 16:03:49 +0000 (09:03 -0700)]
manywarnings: GCC 16 changes
* build-aux/gcc-warning.spec: Add options introduced in GCC 16.
Remove -Wfree-labels (not limited to objc), -Wuseless-cast
(not limited to c++ and objc++).
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Add -Wfree-labels,
-Wkeyword-macro (new to GCC 16), -Wuseless-casts.
Paul Eggert [Fri, 1 May 2026 16:02:37 +0000 (09:02 -0700)]
manywarnings: simplify C warning audits
* build-aux/gcc-warning.spec: Omit many c++, objc, obcj++,
fortran warnings as we no longer need to track them here.
Mark a few of these warnings as now being defaults (for C too).
* m4/manywarnings.m4: In comment that says how to audit this file,
use ‘gcc --help=c,warnings’ and ‘gcc --help=common,warnings’
instead of ‘gcc --help=warnings’, as the latter outputs irrelevant
warnings about c++, objc, obcj++, fortran.
Bruno Haible [Thu, 30 Apr 2026 20:53:21 +0000 (22:53 +0200)]
getlocalename_l-simple tests: Avoid test failure on NetBSD.
* tests/test-getlocalename_l.c (FAKE_COLLATE): New macro.
(main): If FAKE_COLLATE is true, don't compare the result of
getlocalename_l (LC_COLLATE, ...).
* doc/posix-functions/getlocalename_l.texi: Mention the NetBSD bug.
Paul Eggert [Thu, 30 Apr 2026 00:10:56 +0000 (17:10 -0700)]
stdbit-h: namespace cleanup port to G++ 15
For the namespace cleanup, don’t assume that the system <stdbit.h>
defines size_t etc. unless it also defines
__STDC_VERSION_STDBIT_H__. This works around problems with C++
compilers where ‘#include <stdbit.h>’ is a no-op, such as g++ 15.2.1.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2026-04/msg00203.html
It also lets us simplify the code by removing a special case for
the Intel icpx C++ compiler.
* lib/stdbit.in.h: When deciding whether <stdbit.h> works,
use (defined __STDC_VERSION_STDBIT_H__) rather than @HAVE_STDBIT_H@.
This fixes problems when <stdbit.h> works for C so @HAVE_STDBIT_H@
is 1, whereas <stdbit.h> does nothing for C++.
(__STDC_VERSION_STDBIT_H__): Move definition to end.
Paul Eggert [Wed, 29 Apr 2026 22:11:50 +0000 (15:11 -0700)]
stdbit-h: <stddef.h> namespace cleanup
* lib/stdbit.in.h: Include <stddef.h> only if the stdc_memreverse8
module is also used, since it’s the only one that needs size_t.
Define __need_size_t before including <stddef.h>, so that <stddef.h>
defines only size_t on GNU platforms.
Paul Eggert [Wed, 29 Apr 2026 20:58:50 +0000 (13:58 -0700)]
stdbit-h: include <stdint.h> only on module req
This is another attempt to tighten up the <stdbit.h> namespace
on GNU platforms, and follows up on previous C++ fixes here.
* lib/stdbit.in.h: Include <stdint.h> only when also using a
module like stdc_memreverse8 with an API that uses <stdint.h>
types that are not otherwise defined.
This should work better with portable code, as code that merely
wants u?int(_least)?N_t should include <stdint.h>, not <stdbit.h>.
(_GL_STDBIT_UINT_FAST16 _GL_STDBIT_UINT_FAST32)
(_GL_STDBIT_UINT_FAST64): Simplify logic by defining them to the
<stdint.h> equivalents whenever stdint.h is included.
Bruno Haible [Wed, 29 Apr 2026 14:31:30 +0000 (16:31 +0200)]
mbrtoc32-regular: Strengthen the configure test.
* m4/mbrtoc32-regular.m4: New file.
* modules/mbrtoc32-regular (Files): Add it.
(configure.ac): Invoke gl_FUNC_MBRTOC32_REGULAR.
* m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32): Set gl_cv_func_mbrtoc32_regular.
If it's "no" or "guessing no", set REPLACE_MBRTOC32=1.
Bruno Haible [Tue, 28 Apr 2026 23:52:17 +0000 (01:52 +0200)]
error-h: Support multiple gnulib-tool invocations in the same package.
* lib/error.in.h (GNULIB_defined_error, GNULIB_defined_error_at_line):
New macros.
(verror): Test GNULIB_defined_verror, for consistency with the idiom.
(verror_at_line): Test GNULIB_defined_verror_at_line, for consistency
with the idiom.