Article View: comp.std.c
Article #2957Re: strcmp() on a non-nil-terminated string
From: Norman Diamond
Date: Tue, 17 Nov 1992 00:30
Date: Tue, 17 Nov 1992 00:30
24 lines
1710 bytes
1710 bytes
In article <1992Nov16.162313.3334@Urmel.Informatik.RWTH-Aachen.DE> berg@physik.tu-muenchen.de (Stephen R. van den Berg) writes:
>#include <string.h>
>char first[]="first";
>char second[]={'s','e','c','o','n','d'};
[...]
>strcmp(first,second);
>
>Is this program allowed to behave undefined?
ANSI section 4.11.4, page 165 lines 5 to 7, say that the result depends on
the sign of the difference between the first pair of characters that differ.
This doesn't exactly say if the function can continue inspecting irrelevant
characters up to the end of each string.
Section 4.11.4.2 implies that it might inspect each entire string. But the
implication is suspect -- because section 4.11.4.1 (memcmp) has similar
language for the "Returns" paragraph in lines 16 to 17, forgetting the
length limit in the "Description" paragraph in lines 13 to 14.
It might be wise to request an interpretation ruling.
--
Norman Diamond diamond@jit081.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
"It's been a lovely recession."
Technical Details
Message-ID:
<1992Nov17.003044.10870@nntpd.lkg.dec.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!haven.umd.edu!decuac!pa.dec.com!datum.nyo.dec.com!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamondReferences:
<1992Nov16.162313.3334@Urmel.Informatik.RWTH-Aachen.DE>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!haven.umd.edu!decuac!pa.dec.com!datum.nyo.dec.com!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond From: diamond@jit345.bad.jit.dec.com (Norman Diamond) Subject: Re: strcmp() on a non-nil-terminated string Message-ID: <1992Nov17.003044.10870@nntpd.lkg.dec.com> Sender: usenet@nntpd.lkg.dec.com (USENET News System) Reply-To: diamond@jit.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo References: <1992Nov16.162313.3334@Urmel.Informatik.RWTH-Aachen.DE> Date: Tue, 17 Nov 1992 00:30:44 GMT Lines: 24