Paul Eggert wrote:
> * lib/intprops-internal.h: Ignore -Wuseless-cast.
> * lib/vasnprintf.c: Ignore -Wuseless-cast.
These are not entirely correct:
> diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h
> index 0df385b9bf..6a72c24bca 100644
> --- a/lib/intprops-internal.h
> +++ b/lib/intprops-internal.h
> @@ -25,6 +25,11 @@
> # pragma GCC diagnostic ignored "-Wtype-limits"
> #endif
>
> +/* This file uses many casts that might provoke -Wuseless-cast. */
> +#if 16 <= __GNUC__
> +# pragma GCC diagnostic ignored "-Wuseless-cast"
> +#endif
gcc versions 14 and 15 also have the -Wuseless-cast option in C.
The recent manywarnings.m4 change should provoke warnings also with
these older gcc versions. Better silence them as well.
> diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
> index b7c1cfc880..3162fd0b8a 100644
> --- a/lib/vasnprintf.c
> +++ b/lib/vasnprintf.c
> @@ -69,6 +69,11 @@
> # pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
> #endif
>
> +/* This code has a lot of parameterized pointer casts that may be no-ops. */
> +#if _GL_GNUC_PREREQ (16, 0) || 11 <= __clang_major__
> +# pragma GCC diagnostic ignored "-Wuseless-cast"
> +#endif
clang does not support -Wuseless-cast in any version up to 22. In fact,
this '# pragma GCC diagnostic ignored "-Wuseless-cast"' produces a warning:
foo.c:1:33: warning: unknown warning group '-Wuseless-cast', ignored
[-Wunknown-warning-option]
1 | # pragma GCC diagnostic ignored "-Wuseless-cast"
| ^
Hence I apply this followup:
2026-05-08 Bruno Haible <[email protected]>
Revisit some -Wuseless-cast changes.
* lib/intprops-internal.h: Ignore -Wuseless-cast also with gcc 14, 15.
* lib/vasnprintf.c: Likewise. Also, fix a clang warning.
diff --git a/lib/intprops-internal.h b/lib/intprops-internal.h
index 6a72c24bca..a749cad1a4 100644
--- a/lib/intprops-internal.h
+++ b/lib/intprops-internal.h
@@ -25,8 +25,8 @@
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif
-/* This file uses many casts that might provoke -Wuseless-cast. */
-#if 16 <= __GNUC__
+/* This file uses many casts that might provoke -Wuseless-cast warnings. */
+#if 14 <= __GNUC__
# pragma GCC diagnostic ignored "-Wuseless-cast"
#endif
diff --git a/lib/vasnprintf.c b/lib/vasnprintf.c
index 3162fd0b8a..366a437863 100644
--- a/lib/vasnprintf.c
+++ b/lib/vasnprintf.c
@@ -69,8 +69,9 @@
# pragma GCC diagnostic ignored "-Wanalyzer-null-argument"
#endif
-/* This code has a lot of parameterized pointer casts that may be no-ops. */
-#if _GL_GNUC_PREREQ (16, 0) || 11 <= __clang_major__
+/* This code has a lot of parameterized pointer casts that may be no-ops,
+ depending on DCHAR_T and TCHAR_T. */
+#if _GL_GNUC_PREREQ (14, 0)
# pragma GCC diagnostic ignored "-Wuseless-cast"
#endif