Newsgroups: comp.lang.c
Path: utzoo!henry
From: henry@utzoo.uucp (Henry Spencer)
Subject: Re: Bug in ANSI C??
Message-ID: <1988Feb16.142755.11206@utzoo.uucp>
Organization: U of Toronto Zoology
References: <5331@cit-vax.Caltech.Edu> <241@oracle.UUCP> <2118@bsu-cs.UUCP>, <488@slvblc.UUCP>
Date: Tue, 16-Feb-88 14:27:52 EST

> The problem lies in that the developer of the run-time routines is free
> to decide that strcmp() is comparing *signed* eight-bit numbers...

The situation actually gets worse.  Consider strcmp("a\200", "a").  Is its
value positive or negative?  The orthodox rule of lexical ordering says
it should be positive, because strlen("a\200") > strlen("a") and
strncmp("a\200", "a", strlen("a")) == 0.  That is, the '\0' that terminates
the string should not participate in comparisons, and it is irrelevant
whether '\203' < '\0' on a signed-char machine.  Existing implementations
often get this wrong.  The X3J11 draft appears to permit this.  (The wording
is not quite specific enough for me to be certain.)
-- 
Those who do not understand Unix are |  Henry Spencer @ U of Toronto Zoology
condemned to reinvent it, poorly.    | {allegra,ihnp4,decvax,utai}!utzoo!henry
