From: Adhemerval Zanella Netto Date: Tue, 25 Jul 2023 15:16:41 +0000 (-0300) Subject: string: Fix tester build with fortify enable with gcc 6 X-Git-Tag: glibc-2.38~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=784ae968113011ce832b1808d4d42369f5d2e320;p=thirdparty%2Fglibc.git string: Fix tester build with fortify enable with gcc 6 When building with fortify enabled, GCC 6 issues an warning the fortify wrapper might overflow the destination buffer. However, GCC does not provide a specific flag to disable the warning (the failure is tied to -Werror). So to avoid disable all errors, only enable the check for GCC 7 or newer. Checked on i686-linux-gnu. Reviewed-by: Carlos O'Donell --- diff --git a/string/tester.c b/string/tester.c index da42c721418..f7d4bac5a8a 100644 --- a/string/tester.c +++ b/string/tester.c @@ -385,8 +385,17 @@ test_strncat (void) (void) strcpy (one, "gh"); (void) strcpy (two, "ef"); + /* When building with fortify enabled, GCC 6 issues an warning the fortify + wrapper might overflow the destination buffer. However, GCC does not + provide a specific flag to disable the warning (the failure is tied to + -Werror). So to avoid disable all errors, only enable the check for + GCC 7 or newer. */ +#if __GNUC_PREREQ (7, 0) (void) strncat (one, two, 99); equal (one, "ghef", 5); /* Basic test encore. */ +#else + equal (one, "gh", 2); +#endif equal (two, "ef", 6); /* Stomped on source? */ (void) strcpy (one, "");