This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Fix problem with GCC 4.9.1 in string/tester.c
- From: "Carlos O'Donell" <carlos at redhat dot com>
- To: Leonhard Holz <leonhard dot holz at web dot de>, libc-alpha at sourceware dot org, "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Mon, 09 Feb 2015 15:29:09 -0500
- Subject: Re: [PATCH] Fix problem with GCC 4.9.1 in string/tester.c
- Authentication-results: sourceware.org; auth=none
- References: <54D725BC dot 8050604 at web dot de>
On 02/08/2015 04:00 AM, Leonhard Holz wrote:
> tester.c does not compile on my Xubuntu 14.10 with GCC Ubuntu 4.9.1-16ubuntu6. This patch fixes it. Maybe the Ubuntu folks did backport something.
> diff --git a/string/tester.c b/string/tester.c
> index f957ed2..445b427 100644
> --- a/string/tester.c
> +++ b/string/tester.c
> @@ -1305,9 +1305,9 @@ test_memset (void)
> equal(one, "axxxefgh", 2); /* Basic test. */
> -#if __GNUC_PREREQ (5, 0)
> - /* GCC 5.0 warns about a zero-length memset because the arguments to memset
> - may be in the wrong order. But we really want to test this. */
> +#if __GNUC_PREREQ (5, 0) || __GNUC_PREREQ (4, 9)
> + /* GCC 5.0 / 4.9 warns about a zero-length memset because the arguments to
> + memset may be in the wrong order. But we really want to test this. */
> DIAG_IGNORE_NEEDS_COMMENT (5.0, "-Wmemset-transposed-args")
> (void) memset(one+2, 'y', 0);
As Andreas states, FSF GCC 4.9 doesn't actually have this problem. Bare GCC
version references are always for the canonical upstream version.
So what is the correct fix?
You and I have talked before about testing for compiler features rather
Do you think the correct fix is to test for the warning at configure time,
set HAVE_WARN_MEMSET_TRANSPOSED_ARGS in config.h, and then use that to
conditionalize the DIAG_* statements?
I don't see any other way to have this work.
The configure check would need a detailed comment about exactly which
compiler has this feature backported that's causing problems.
Thankfully this is just a test and not an installed header.