stddef: A better workaround against GCC bug 114870.
authorBruno Haible <bruno@clisp.org>
Wed, 1 May 2024 22:10:21 +0000 (00:10 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 1 May 2024 22:10:21 +0000 (00:10 +0200)
* lib/stddef.in.h: If STDDEF_NOT_IDEMPOTENT is 1, disable the special
invocation convention.
* m4/stddef_h.m4 (gl_STDDEF_H): Set STDDEF_NOT_IDEMPOTENT.
(gl_STDDEF_H_DEFAULTS): Initialize STDDEF_NOT_IDEMPOTENT.
* modules/stddef (Makefile.am): Substitute STDDEF_NOT_IDEMPOTENT.

ChangeLog
lib/stddef.in.h
m4/stddef_h.m4
modules/stddef

index 21e52879f6d1166cc91d15640b41281d171ef4c4..54239ffcc3a2fd058b5353532b7923644a05c923 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-05-01  Bruno Haible  <bruno@clisp.org>
+
+       stddef: A better workaround against GCC bug 114870.
+       * lib/stddef.in.h: If STDDEF_NOT_IDEMPOTENT is 1, disable the special
+       invocation convention.
+       * m4/stddef_h.m4 (gl_STDDEF_H): Set STDDEF_NOT_IDEMPOTENT.
+       (gl_STDDEF_H_DEFAULTS): Initialize STDDEF_NOT_IDEMPOTENT.
+       * modules/stddef (Makefile.am): Substitute STDDEF_NOT_IDEMPOTENT.
+
 2024-05-01  Bruno Haible  <bruno@clisp.org>
 
        stddef: Fix <stddef.h> behaviour on Cygwin (regression 2024-04-27).
index ac81257b5cfff513c52c5b971d7fe92e9546bdf1..63bb500e2621faf2774a8b369a0aed055c7c8cf6 100644 (file)
 #endif
 @PRAGMA_COLUMNS@
 
-#if (defined __need_wchar_t || defined __need_size_t \
-     || defined __need_ptrdiff_t || defined __need_NULL \
-     || defined __need_wint_t)
+#if (defined __need_wchar_t || defined __need_size_t                \
+     || defined __need_ptrdiff_t || defined __need_NULL             \
+     || defined __need_wint_t)                                      \
+    /* Avoid warning triggered by "gcc -std=gnu23 -Wsystem-headers" \
+       in Fedora 40 with gcc 14.0.1.                                \
+       <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870>.  */   \
+    && !@STDDEF_NOT_IDEMPOTENT@
 /* Special invocation convention inside gcc header files.  In
    particular, <stddef.h> in some ancient versions of GCC blindly
    redefined NULL when __need_wint_t was defined, even though wint_t
 # endif
 
 #else
+/* For @STDDEF_NOT_IDEMPOTENT@.  */
+# undef __need_wchar_t
+# undef __need_size_t
+# undef __need_ptrdiff_t
+# undef __need_NULL
+# undef __need_wint_t
+
 /* Normal invocation convention.  */
 
 # ifndef _@GUARD_PREFIX@_STDDEF_H
index 0d4ddf8fcb0aeb486373d834b4878018bddb16aa..998fe12fa83e9819954dfc46423f2b421ad3cedd 100644 (file)
@@ -1,5 +1,5 @@
 # stddef_h.m4
-# serial 15
+# serial 16
 dnl Copyright (C) 2009-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -110,6 +110,7 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
         [gl_cv_clean_version_stddef=yes],
         [gl_cv_clean_version_stddef=no])])
   if test "$gl_cv_clean_version_stddef" = no; then
+    STDDEF_NOT_IDEMPOTENT=1
     GL_GENERATE_STDDEF_H=true
   fi
 
@@ -144,6 +145,7 @@ AC_DEFUN([gl_STDDEF_H_DEFAULTS],
 [
   dnl Assume proper GNU behavior unless another module says otherwise.
   NULLPTR_T_NEEDS_STDDEF=1;      AC_SUBST([NULLPTR_T_NEEDS_STDDEF])
+  STDDEF_NOT_IDEMPOTENT=0;       AC_SUBST([STDDEF_NOT_IDEMPOTENT])
   REPLACE_NULL=0;                AC_SUBST([REPLACE_NULL])
   HAVE_MAX_ALIGN_T=1;            AC_SUBST([HAVE_MAX_ALIGN_T])
   HAVE_WCHAR_T=1;                AC_SUBST([HAVE_WCHAR_T])
index 4096ab955d4b0a98ae9e3e4f0f169bcb97d08fde..9a80db007bf5fa0c5184c68c16ce67ba6ad4f62f 100644 (file)
@@ -31,10 +31,11 @@ stddef.h: stddef.in.h $(top_builddir)/config.status
              -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
              -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
              -e 's|@''NEXT_STDDEF_H''@|$(NEXT_STDDEF_H)|g' \
-             -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
-             -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
              -e 's|@''NULLPTR_T_NEEDS_STDDEF''@|$(NULLPTR_T_NEEDS_STDDEF)|g' \
+             -e 's|@''STDDEF_NOT_IDEMPOTENT''@|$(STDDEF_NOT_IDEMPOTENT)|g' \
              -e 's|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
+             -e 's|@''HAVE_MAX_ALIGN_T''@|$(HAVE_MAX_ALIGN_T)|g' \
+             -e 's|@''HAVE_WCHAR_T''@|$(HAVE_WCHAR_T)|g' \
              $(srcdir)/stddef.in.h > $@-t
        $(AM_V_at)mv $@-t $@
 else