From: Paul Eggert Date: Sat, 27 Apr 2024 16:09:38 +0000 (-0700) Subject: stddef: work around a GCC 14 stddef.h bug X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=fda77dba48c500bbd61f1ae93f488a34f02ac2d1;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index de52b89a3a..7d9dbb506f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-04-27 Paul Eggert + + 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 login_tty tests: Avoid gcc warnings. diff --git a/lib/stddef.in.h b/lib/stddef.in.h index 190fd575d8..6c05fbfe28 100644 --- a/lib/stddef.in.h +++ b/lib/stddef.in.h @@ -1,6 +1,6 @@ /* A substitute for POSIX 2008 , 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 + . */ +# define _GCC_NULLPTR_T +# endif + /* The include_next requires a split double-inclusion guard. */ # @INCLUDE_NEXT@ @NEXT_STDDEF_H@ diff --git a/m4/stddef_h.m4 b/m4/stddef_h.m4 index aa012219fc..ee94128e19 100644 --- a/m4/stddef_h.m4 +++ b/m4/stddef_h.m4 @@ -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 ], + [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 + #undef __STDC_VERSION_STDDEF_H__ + #include + #ifdef __STDC_VERSION_STDDEF_H__ + # error " 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]) diff --git a/modules/stddef b/modules/stddef index fb7214138e..4096ab955d 100644 --- a/modules/stddef +++ b/modules/stddef @@ -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 $@