On Apr 24, 12:38, Paul E Coad wrote:
> On Fri, 24 Apr 1998, Captain Napalm wrote:
> > It was thus said that the Great Pete Turnbull once stated:
> > >
> > > On Apr 24, 1:35, Captain Napalm wrote:
> > > > strcpy() (at least on my compiler) will crash if any of the
> > > > parameters are NULL pointers,
> > >
> > > That's a compiler (or library, actually) bug. You should be able to
> > > copy a null string.
> >
> > Well, I've tried it across four platforms and five compilers
> > (Linux/GCC, Solaris/native and GCC, AIX/native and HPUX/native) and
> > three of the five core dumped.
> >
> The ANSI standard is not completely silent on the matter, but does not
> define the behavior.
>
> "Each of the following statements applies unless explicitly stated
> otherwise in the detailed descriptions that follow. If an argument
> to a function has an invalid value (such as a value outside of the
> domain of the function, or a pointer outside the address space of
> the program or a null pointer), the behavior is undefined."
Well, whether I think that's sensible or not ('cos I think you ought to be
able to copy a null string), if ANSI says it's undefined, then it's not a
bug. I take it back. And thanks for checking, which I was too lazy to do
:-)
--
Pete Peter Turnbull
Dept. of Computer Science
University of York
Received on Fri Apr 24 1998 - 19:32:02 BST