From aeb89f6ad6f3cdefb67b026cbe73de839af692a1 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 18 Mar 2025 12:56:31 -0500 Subject: [PATCH] configure: add -Werror=array-bounds to CFLAGS when available This would have prevented https://bugs.gnu.org/76907 * configure.ac: add -Werror=array-bounds to CFLAGS when available --- NEWS | 5 +++++ configure.ac | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/NEWS b/NEWS index 394a7a78d..2adbdf099 100644 --- a/NEWS +++ b/NEWS @@ -47,6 +47,11 @@ every line in a file. * Changes to the distribution +* Build system changes + +** -Werror=array-bounds is now added to CFLAGS when available + This catches + * Bug fixes ** `basename` now checks the suffix against the base name, not the full path diff --git a/configure.ac b/configure.ac index f3a05ec70..eb2744b61 100644 --- a/configure.ac +++ b/configure.ac @@ -62,6 +62,14 @@ AC_PROG_INSTALL AC_PROG_CC gl_EARLY +AC_MSG_CHECKING([whether the compiler supports -Werror=array-bounds]) +old_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -Werror=array-bounds" +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo;], [])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + CFLAGS="$old_CFLAGS"]) + AC_MSG_CHECKING([whether the compiler supports -fexcess-precision=standard]) old_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fexcess-precision=standard"