Bruno Haible [Wed, 13 May 2026 10:51:40 +0000 (12:51 +0200)]
intprops: Fix compilation error in MSVC.
* lib/intprops.h (TYPE_IS_INTEGER, TYPE_MINIMUM, TYPE_MAXIMUM): Don't
use _Generic to distinguish between 'char' and 'signed char' with MSVC
before version 14.44.
* lib/intprops-internal.h (_GL_TYPE_SIGNED): Likewise.
Bruno Haible [Tue, 12 May 2026 08:49:49 +0000 (10:49 +0200)]
stdc_bit_floor, stdc_bit_ceil: Work around Solaris 11 OpenIndiana bug.
* lib/stdbit.in.h (stdc_bit_floor, stdc_bit_ceil): Override the macro
definition from Solaris 11.
* doc/posix-functions/stdc_bit_floor.texi: Mention the Solaris 11
OpenIndiana bug.
* doc/posix-functions/stdc_bit_ceil.texi: Likewise.
Bruno Haible [Mon, 11 May 2026 19:15:44 +0000 (21:15 +0200)]
gettext-h: Ensure no warnings with --disable-nls and -Wformat=2.
* lib/gettext.h (gettext, dgettext, dcgettext): Define differently for
clang.
(ngettext, dngettext, dcngettext): Define differently for gcc and clang.
With gcc in C mode, silence -Wuseless-cast warnings.
Paul Eggert [Mon, 11 May 2026 17:20:45 +0000 (10:20 -0700)]
careadlinkat: pacify GCC 12+ -Wreturn-local-addr more simply
* lib/careadlinkat.c (readlink_stk):
Now also noinline when _GL_GNUC_PREREQ (12, 1) && !USING_LTO.
The small inlining performance improvement for GCC 12+ was not worth
the hassle of documenting or autoconfiguring USING_LTO.
This change removes the need for USING_LTO.
Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2026-05/msg00103.html
Paul Eggert [Mon, 11 May 2026 03:55:24 +0000 (20:55 -0700)]
intprops: ignore -Wuseless-cast less often
Using _Generic instead of casting should help includers of
<intprops.h> to avoid suppression of -Wuseless-cast diagnostics.
* lib/intprops-internal.h: Ignore -Wuseless-cast only
if (__STDC_VERSION__ < 201112 && 14 <= __GNUC__).
(_GL__GENERIC_BOGUS): Move definition up.
* lib/intprops-internal.h (_GL_TYPE_SIGNED):
* lib/intprops.h (TYPE_IS_INTEGER, TYPE_MINIMUM, TYPE_MAXIMUM):
Use _Generic if this should work, to avoid the need for casts.
* lib/intprops-internal.h (_GL_INT_NEGATE_OVERFLOW):
* lib/intprops.h (_GL_ADD_OVERFLOW, _GL_SUBTRACT_OVERFLOW)
(_GL_MULTIPLY_OVERFLOW): When _GL_HAS_BUILTIN_OVERFLOW_P, use
_GL_INT_CONVERT to avoid the need for a cast.
Paul Eggert [Mon, 11 May 2026 01:44:40 +0000 (18:44 -0700)]
regex: omit useless casts
* lib/regex_internal.c (build_wcs_upper_buffer):
Omit cast from char * to char *.
* lib/regex_internal.h (re_string_wchar_at):
Omit casts to wint_t in a context that will already convert to wint_t.
Paul Eggert [Sun, 10 May 2026 20:52:28 +0000 (13:52 -0700)]
manywarnings: add -Wstringop-overflow=4
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC(C)): Add
-Wstringop-overflow=4. This option, when used with GCC 16, works
with current Gnulib and with coreutils, so it seems like a good
thing to add to the default list.
Paul Eggert [Sun, 10 May 2026 20:09:27 +0000 (13:09 -0700)]
careadlinkat: pacify GCC 16 -flto
Use a simpler scheme to pacify GCC.
* lib/careadlinkat.c (readlink_stk): With GCC 12+,
do not ignore -Wreturn-local-addr if -flto is being used,
as this does not work with current coreutils and with
gcc 16.1.1 20260501 (Red Hat 16.1.1-1) x86-64.
Instead, fall back on __attribute__ ((__noinline__)).
(GCC_BOGUS_WRETURN_LOCAL_ADDR): Remove. Do not bother
with this as it complicates maintenance and is present only
for better diagnostics in older compilers.
Just use __attribute__ ((__noinline__)) instead.
All uses removed.
Paul Eggert [Sun, 10 May 2026 18:23:37 +0000 (11:23 -0700)]
chown: use AC_CHECK_HEADERS_ONCE on standard headers
* m4/chown.m4 (AC_FUNC_CHOWN):
* m4/size_max.m4 (gl_SIZE_MAX):
* m4/xsize.m4 (gl_XSIZE): Prefer AC_CHECK_HEADERS_ONCE to
AC_CHECK_HEADERS for standard headers that Autoconf will use
AC_CHECK_HEADERS_ONCE on anyway.
Paul Eggert [Sun, 10 May 2026 18:20:07 +0000 (11:20 -0700)]
canonicalize: use stdckdint.h not intprops.h
canonicalize: use stdckdint.h not intprops.h
<stdckdint.h> is standard, so prefer that to the pre-standard
intprops.h.
* lib/canonicalize.c: Include stdckdint.h, not intprops.h.
(canonicalize_filename_mode_stk): Use ckd_add, not INT_ADD_OVERFLOW.
* modules/canonicalize (Depends-on): Remove intprops.
Add stdckdint-h. Sort.
Paul Eggert [Sun, 10 May 2026 17:35:50 +0000 (10:35 -0700)]
canonicalize: pacify -Wmaybe-uninitialized without ignoring
* lib/canonicalize.c: Do not ignore -Wmaybe-uninitialized.
(IF_LINT): Remove; no longer used.
(canonicalize_filename_mode_stk): Use a single local rather than two.
Ordinarily portmanteau variables are iffy, but this one is a win.
Bruno Haible [Sun, 10 May 2026 22:10:44 +0000 (00:10 +0200)]
Revisit some -Wuseless-cast changes.
* lib/fstrcmp.c (fstrcmp_free_resources, fstrcmp_bounded): Use a
compound literal to convert to uintptr_t.
* lib/wait-process.c (wait_subprocess): Use a compound literal to
convert to int.
* lib/sigsegv.c: Revert last change. Instead, disable -Wuseless-cast
in this compilation unit.
* tests/jit/test-cache.c: Likewise.
* tests/test-limits-h.c: Disable -Wuseless-cast warnings also for
gcc 14, 15.
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.