Subject: Re: kern/13369: gcc inlines memcpy(3)
To: None <minoura@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: netbsd-bugs
Date: 07/04/2001 20:49:22
On Wed, Jul 04, 2001 at 10:03:23AM +0900, minoura@netbsd.org wrote:
>
> >Number: 13369
> >Category: kern
> >Synopsis: gcc inlines memcpy(3)
> >Confidential: no
> >Severity: serious
> >Priority: high
> >Responsible: kern-bug-people
> >State: open
> >Class: sw-bug
> >Submitter-Id: net
> >Arrival-Date: Tue Jul 03 18:01:00 PDT 2001
> >Closed-Date:
> >Last-Modified:
> >Originator: Minoura Makoto
> >Release: 20010612
> >Organization:
> Minoura Makoto <minoura@netbsd.org>
> The NetBSD Project/Japan NetBSD Users' Group
> >Environment:
> System: NetBSD daisy 1.5W NetBSD 1.5W (DAISY) #190: Mon Jun 25 14:28:07 JST 2001 root@daisy:/usr/obj/sys/arch/i386/compile/DAISY i386
> gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
> Architecture: i386
> Machine: i386
> >Description:
> gcc -O inlines the following memcpy(3) call (at least on i386):
>
> #include <string.h>
>
> extern char buf[];
>
> void testfunc(char *src)
> {
> memcpy(buf, src, 100);
> }
>
> The inlined memcpy() gets insane when the two buffers are
> overlapping.
>
> On the other hand, kernel bcopy() is #define'ed as memcpy() in
> /sys/sys/systm.h.
>
> This might cause a problem that when the programmer
> wants to transfer overlapping strings using bcopy()
> they might be destroyed as a result.
Shouldn't we just replace calls to bcopy with memmove or memcpy, as
appropriate ?
--
Manuel Bouyer <bouyer@antioche.eu.org>
--