From: Francesco Chemolli Date: Fri, 22 Jul 2022 23:12:33 +0000 (+0000) Subject: Silence GnuRegex warnings on gcc 12.1 (#1096) X-Git-Tag: SQUID_5_7~7 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=dde32ed532c848f59ee122cf1d70fbbd597c2aa1;p=thirdparty%2Fsquid.git 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. --- diff --git a/compat/GnuRegex.c b/compat/GnuRegex.c index 9ef932e5ca..82c912939f 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