home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ogicse!emory!sol.ctr.columbia.edu!eff!world!ksr!jfw
- From: jfw@ksr.com (John F. Woods)
- Newsgroups: comp.std.c
- Subject: Re: strcmp() on a non-nil-terminated string
- Message-ID: <18866@ksr.com>
- Date: 17 Nov 92 17:38:22 GMT
- Article-I.D.: ksr.18866
- References: <1992Nov16.162313.3334@Urmel.Informatik.RWTH-Aachen.DE>
- Sender: news@ksr.com
- Lines: 22
-
- berg@physik.tu-muenchen.de (Stephen R. van den Berg) writes:
- >char first[]="first";
- >char second[]={'s','e','c','o','n','d'};
- >main()
- >{ return!!strcmp(first,second);
- >}
- >--------------------------------------
- >Is this program allowed to behave undefined?
-
- 4.1.1 Definitions of Terms "A string is a contiguous sequence of characters
- terminated by and including the first null character."
- 4.11.1 String Function Conventions "If an array is accessed beyond the end
- of an object, the behavior is undefined."
- 4.11.4.2 The strcmp Function "The strcmp function compares the string pointed
- ^^^^^^
- to by s1 to the string pointed to by s2." (emphasis added)
- ^^^^^^
-
- >You would expect a sane implementation to return with an exitcode of 1.
-
- *I* would expect a sane programmer to read and understand the manual before
- plugging in the C compiler.
-