]> Savannah Git Hosting - gnulib.git/commitdiff
stddef: work around a GCC 14 stddef.h bug
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 27 Apr 2024 16:09:38 +0000 (09:09 -0700)
committerBruno Haible <bruno@clisp.org>
Fri, 17 May 2024 23:18:46 +0000 (01:18 +0200)
* lib/stddef.in.h: (_GCC_NULLPTR_T): Define if needed to work around
GCC bug 114869.
* m4/stddef_h.m4 (gl_STDDEF_H, gl_STDDEF_H_DEFAULTS):
* modules/stddef (stddef.h):
Detect the two bugs 114869 and 114870.

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

index de52b89a3a8adf00ceee65c4b4d7df729e352cd1..7d9dbb506f3769f3507d432bd1d3251606fe60ba 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-04-27  Paul Eggert  <eggert@cs.ucla.edu>
+
+       stddef: work around a GCC 14 stddef.h bug
+       * lib/stddef.in.h: (_GCC_NULLPTR_T): Define if needed to work around
+       GCC bug 114869.
+       * m4/stddef_h.m4 (gl_STDDEF_H, gl_STDDEF_H_DEFAULTS):
+       * modules/stddef (stddef.h):
+       Detect the two bugs 114869 and 114870.
+
 2024-04-26  Bruno Haible  <bruno@clisp.org>
 
        login_tty tests: Avoid gcc warnings.
index 190fd575d8d9687e0d6ae183a003877bfc62bdbe..6c05fbfe2835c8169ca84c9b906064422de21e23 100644 (file)
@@ -1,6 +1,6 @@
 /* A substitute for POSIX 2008 <stddef.h>, for platforms that have issues.
 
-   Copyright (C) 2009-2023 Free Software Foundation, Inc.
+   Copyright (C) 2009-2024 Free Software Foundation, Inc.
 
    This file is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as
@@ -74,6 +74,12 @@ typedef long max_align_t;
 #   endif
 #  endif
 
+#  if !defined _GCC_NULLPTR_T && !@NULLPTR_T_NEEDS_STDDEF@
+    /* Suppress unwanted nullptr_t typedef.  See
+       <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114869>.  */
+#   define _GCC_NULLPTR_T
+#  endif
+
 /* The include_next requires a split double-inclusion guard.  */
 
 #  @INCLUDE_NEXT@ @NEXT_STDDEF_H@
index aa012219fcd39a322abd3874e6ae4d50e4f97822..ee94128e199c8ca0b9bc477605f0c1a6826d15b8 100644 (file)
@@ -1,5 +1,5 @@
-# stddef_h.m4 serial 14
-dnl Copyright (C) 2009-2023 Free Software Foundation, Inc.
+# stddef_h.m4 serial 15
+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,
 dnl with or without modifications, as long as this notice is preserved.
@@ -83,6 +83,35 @@ AC_DEFUN_ONCE([gl_STDDEF_H],
     GL_GENERATE_STDDEF_H=true
   fi
 
+  dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114869
+  AC_CACHE_CHECK([whether nullptr_t needs <stddef.h>],
+    [gl_cv_nullptr_t_needs_stddef],
+    [AC_COMPILE_IFELSE([AC_LANG_DEFINES_PROVIDED[nullptr_t x;]],
+       [gl_cv_nullptr_t_needs_stddef=no],
+       [gl_cv_nullptr_t_needs_stddef=yes])])
+  if test "$gl_cv_nullptr_t_needs_stddef" = no; then
+    NULLPTR_T_NEEDS_STDDEF=0
+    GL_GENERATE_STDDEF_H=true
+  fi
+
+  AC_CACHE_CHECK([for clean definition of __STDC_VERSION_STDDEF_H__],
+    [gl_cv_clean_version_stddef],
+    [AC_PREPROC_IFELSE(
+       [AC_LANG_SOURCE(
+          [[/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870 */
+            #include <stddef.h>
+            #undef __STDC_VERSION_STDDEF_H__
+            #include <time.h>
+            #ifdef __STDC_VERSION_STDDEF_H__
+            # error "<time.h> defines __STDC_VERSION_STDDEF_H__"
+            #endif
+          ]])],
+        [gl_cv_clean_version_stddef=yes],
+        [gl_cv_clean_version_stddef=no])])
+  if test "$gl_cv_clean_version_stddef" = no; then
+    GL_GENERATE_STDDEF_H=true
+  fi
+
   if $GL_GENERATE_STDDEF_H; then
     gl_NEXT_HEADERS([stddef.h])
   fi
@@ -113,6 +142,7 @@ AC_DEFUN([gl_STDDEF_H_REQUIRE_DEFAULTS],
 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])
   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 fb7214138e670429b9d93d44b372ce74432ef8a0..4096ab955d4b0a98ae9e3e4f0f169bcb97d08fde 100644 (file)
@@ -33,6 +33,7 @@ stddef.h: stddef.in.h $(top_builddir)/config.status
              -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|@''REPLACE_NULL''@|$(REPLACE_NULL)|g' \
              $(srcdir)/stddef.in.h > $@-t
        $(AM_V_at)mv $@-t $@