Re: [PATCH] C undefined behavior fix

From: Daniel Jacobowitz (dmj+@andrew.cmu.edu)
Date: Thu Jan 03 2002 - 16:26:46 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jan 07 2002 - 21:00:22 EST