Orgad Shaneh wrote:
> I found the warning now:
> ../../lib/malloca.c:61: warning: comparison is always false due to
> limited range of data type
> 
> Context:
>      59   int plus = sizeof (small_t) + alignment2_mask;
>      60   idx_t nplus;
>      61   if (!ckd_add (&nplus, n, plus) && !xalloc_oversized (nplus, 1))

These -Wtype-limits warnings are most often harmless. Their causes are:
  - types like 'char' that are signed on some platforms and unsigned on others,
  - comparisons with SIZE_MAX or UINT_MAX or so, that happen to be the maximum
    value of a certain type on some platforms but not on others.

> I also have this with the same toolchain:
> ../../lib/gettext.h:79: warning: '__gnu_inline__' attribute directive ignored
> (and same for lines 88 and 98).
> 
> Context:
>      62 /* Disabled NLS.  */
>      63 # if defined __GNUC__ && !defined __clang__ && !defined __cplusplus
>      64 /* Use inline functions, to avoid warnings
>      65      warning: format not a string literal and no format arguments
>      66    that don't occur with enabled NLS.  */
>      67 /* The return type 'const char *' serves the purpose of
> producing warnings
>      68    for invalid uses of the value returned from these functions.  */
>      69 #  if __GNUC__ >= 9
>      70 #   pragma GCC diagnostic push
>      71 #   pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
>      72 #  endif
>      73 __attribute__ ((__always_inline__, __gnu_inline__)) extern inline
>      74 #  if !defined(__sun)
>      75 const
>      76 #  endif
>      77 char *
>      78 gettext (const char *msgid)

Thanks for reporting this one. The __gnu_inline__ is not needed for gcc
versions < 4.2, since with these old gcc versions the 'inline' keyword
had the same semantics that 'gnu_inline' does today. We lose nothing by
silencing this warning:


2025-09-13  Bruno Haible  <[email protected]>

        gettext-h: Avoid warning with gcc < 4.2.
        Reported by Orgad Shaneh <[email protected]> in
        <https://lists.gnu.org/archive/html/bug-gnulib/2025-09/msg00183.html>.
        * lib/gettext.h (gettext, dgettext, dcgettext): Don't use attribute
        __gnu_inline__ with gcc < 4.2.

diff --git a/lib/gettext.h b/lib/gettext.h
index fd6c62b7eb..0650abc9a3 100644
--- a/lib/gettext.h
+++ b/lib/gettext.h
@@ -70,7 +70,12 @@
 #   pragma GCC diagnostic push
 #   pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
 #  endif
-__attribute__ ((__always_inline__, __gnu_inline__)) extern inline
+#  if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
+__attribute__ ((__always_inline__, __gnu_inline__))
+#  else
+__attribute__ ((__always_inline__))
+#  endif
+extern inline
 #  if !defined(__sun)
 const
 #  endif
@@ -79,7 +84,12 @@ gettext (const char *msgid)
 {
   return msgid;
 }
-__attribute__ ((__always_inline__, __gnu_inline__)) extern inline
+#  if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
+__attribute__ ((__always_inline__, __gnu_inline__))
+#  else
+__attribute__ ((__always_inline__))
+#  endif
+extern inline
 #  if !defined(__sun)
 const
 #  endif
@@ -89,7 +99,12 @@ dgettext (const char *domain, const char *msgid)
   (void) domain;
   return msgid;
 }
-__attribute__ ((__always_inline__, __gnu_inline__)) extern inline
+#  if __GNUC__ + (__GNUC_MINOR__ >= 2) > 4
+__attribute__ ((__always_inline__, __gnu_inline__))
+#  else
+__attribute__ ((__always_inline__))
+#  endif
+extern inline
 #  if !defined(__sun)
 const
 #  endif




Reply via email to