Re: [PATCH] C undefined behavior fix

Daniel Jacobowitz
2002-01-03T21:26:46Z

On Thu, Jan 03, 2002 at 12:35:30AM +0000, David Woodhouse wrote:
>
> (cc list trimmed)
>
> alan@lxorguk.ukuu.org.uk said:
> > If you want a strcpy that isnt strcpy then change its name or use a
> > different language 8)
>
> The former is not necessarily sufficient in this case. You've still done the
> broken pointer arithmetic, so even if the function isn't called strcpy() the
> compiler is _still_ entitled to replace it with a call to memcpy() or even
> machine_restart() before sleeping with your mother and starting WW III.

No, that's not true. We're passing a pointer as an argument. It is a
valid pointer - dereferencing it may not be valid, but the pointer is
perfectly legal! There is nothing wrong with this case. The problem
lies in calling a function whose name is special to GCC and to the C
language, which GCC can then transform.

--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer