* lib/regex_internal.h (re_malloc): Rewrite so that callers
don’t do the equivalent of !(2 * n), which elicits the warning.
---
 ChangeLog            | 6 ++++++
 lib/regex_internal.h | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index a2bca1ce98..32a8a88136 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2026-04-28  Paul Eggert  <[email protected]>
+
+       regex: pacify gcc -Wint-in-bool-context
+       * lib/regex_internal.h (re_malloc): Rewrite so that callers
+       don’t do the equivalent of !(2 * n), which elicits the warning.
+
 2026-04-28  Bruno Haible  <[email protected]>
 
        windows-cygpath: Handle UNC file names on Cygwin correctly.
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index c4e05ec72d..e24ef97989 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -451,7 +451,7 @@ typedef struct re_dfa_t re_dfa_t;
 #if defined _LIBC || HAVE_MALLOC_0_NONNULL
 # define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
 #else
-# define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t) + !(n)))
+# define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t) + ((n) == 0)))
 #endif
 #define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
 #define re_free(p) free (p)
-- 
2.53.0


Reply via email to