This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix problem with GCC 4.9.1 in string/tester.c


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. */
> 
>    DIAG_PUSH_NEEDS_COMMENT;
> -#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")
>  #endif
>    (void) memset(one+2, 'y', 0);

Leonhard,

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?

Good question.

Joseph,

You and I have talked before about testing for compiler features rather
than version.

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.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]