]> Savannah Git Hosting - gnulib.git/commitdiff
nullptr: work around GCC 14 nullptr sentinel bug
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 27 Apr 2024 17:31:45 +0000 (10:31 -0700)
committerBruno Haible <bruno@clisp.org>
Fri, 17 May 2024 22:50:01 +0000 (00:50 +0200)
* m4/nullptr.m4 (gl_NULLPTR): Work around GCC bug 114780.

ChangeLog
m4/nullptr.m4

index 5713aa94ef1797cba0ddc4c31afb37e406447de9..22fa02383c2f3009db8dc896dba33e778128c54e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2024-04-27  Paul Eggert  <eggert@cs.ucla.edu>
+
+       nullptr: work around GCC 14 nullptr sentinel bug
+       * m4/nullptr.m4 (gl_NULLPTR): Work around GCC bug 114780.
+
 2024-04-27  Paul Eggert  <eggert@cs.ucla.edu>
 
        stddef: work around a GCC 14 stddef.h bug
index f5721e5c33ae3c97e06bd6b434537624fe9510fe..ac3788d70b619c27eaefd62bc76b938946432188 100644 (file)
@@ -12,7 +12,21 @@ AC_DEFUN([gl_NULLPTR],
      AC_CACHE_CHECK([for C nullptr], [gl_cv_c_nullptr],
        [AC_COMPILE_IFELSE(
           [AC_LANG_SOURCE([[int *p = nullptr;]])],
-          [gl_cv_c_nullptr=yes],
+          [gl_cv_c_nullptr=yes
+           # Work around <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114780>.
+           gl_saved_CFLAGS=$CFLAGS
+           CFLAGS="$CFLAGS -Wall -Werror"
+           AC_COMPILE_IFELSE(
+             [AC_LANG_PROGRAM(
+                [[void f (char const *, ...) __attribute__ ((sentinel));]],
+                [[f ("", nullptr);]])],
+             [],
+             [AC_COMPILE_IFELSE(
+                [AC_LANG_PROGRAM(
+                   [[void f (char const *, ...) __attribute__ ((sentinel));]],
+                   [[f ("", (void *) 0);]])],
+                [gl_cv_c_nullptr='not as a sentinel'])])
+           CFLAGS=$gl_saved_CFLAGS],
           [gl_cv_c_nullptr=no])])
       gl_c_nullptr=$gl_cv_c_nullptr
       AC_LANG_POP([C])],