Bug in ANSI C??
Henry Spencer
henry at utzoo.uucp
Wed Feb 17 05:27:52 AEST 1988
> 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
More information about the Comp.lang.c
mailing list