This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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: Fix memrchr


On Mon, Jan 06, 2003 at 04:33:21PM +0100, Andreas Jaeger wrote:
> 
> The first memrchr testcase in string/inl-tester failed for me with GCC
> 3.4.  Looking closer into it, Honza noticed that it is not valid C,
> the arithmetic is wrong.

Not valid C, but a documented GCC extension (see extend.texi).
If it doesn't work, it is a GCC bug.

> --- sysdeps/i386/i486/bits/string.h	4 Dec 2002 12:27:43 -0000	1.51
> +++ sysdeps/i386/i486/bits/string.h	6 Jan 2003 15:10:00 -0000
> @@ -1,5 +1,5 @@
>  /* Optimized, inlined string functions.  i486 version.
> -   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
> +   Copyright (C) 1997,1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
>     This file is part of the GNU C Library.
>  
>     The GNU C Library is free software; you can redistribute it and/or
> @@ -472,7 +472,7 @@ __memrchr (__const void *__s, int __c, s
>  # ifdef __i686__
>    register unsigned long int __d1;
>  # endif
> -  register void *__res;
> +  register int __res;
>    if (__n == 0)
>      return NULL;
>  # ifdef __i686__
> @@ -497,7 +497,7 @@ __memrchr (__const void *__s, int __c, s
>         "m" ( *(struct { __extension__ char __x[__n]; } *)__s)
>       : "cc");
>  # endif
> -  return __res + 1;
> +  return (void *)(__res + 1);
>  }
>  # ifdef __USE_GNU
>  #  define memrchr(s, c, n) __memrchr (s, c, n)

	Jakub


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