From f562f5ce5db10be506960b4294942fc140631cfa Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Fri, 22 Jul 2022 23:12:33 +0000 Subject: [PATCH] Silence GnuRegex warnings on gcc 12.1 (#1096) GnuRegex does pointer magic that gcc 12.1 doesn't like. compat/GnuRegex.c: error: array subscript -1 is outside array bounds of 'const char[]' [-Werror=array-bounds] compat/GnuRegex.c: error: pointer may be used after 'realloc' [-Werror=use-after-free] A long term fix is to unship GnuRegex which is an old snapshot and is not maintained. --- compat/GnuRegex.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compat/GnuRegex.c b/compat/GnuRegex.c index 911c810dfd..fd03664089 100644 --- a/compat/GnuRegex.c +++ b/compat/GnuRegex.c @@ -40,6 +40,13 @@ #if USE_GNUREGEX /* only if squid needs it. Usually not */ +/* Starting with v12.1, GCC warns of various problems with this ancient code. */ +/* GCC versions prior to v12.1 do not support these pragmas. */ +#if (__GNUC__ == 12 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 12) +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wuse-after-free" +#endif + #if !HAVE_ALLOCA #define REGEX_MALLOC 1 #endif -- 2.47.2