Subject: Re: lib/1764: __ivaliduser() contains call to abort()
To: None <netbsd-bugs@NetBSD.ORG>
From: Ty Sarna <>
List: netbsd-bugs
Date: 11/16/1995 18:05:37
In article <199511161338.OAA00677@kurt.Tools.DE>,
Wolfgang Solfrank  <> wrote:
> > Actually, there are other stylistic no-nos in rcmd.c (assuming boolean
> > value of a == b is either 0 or 1),
> And what's wrong with this?

It is allowed (ANSI C 6.3.8). However, the reason I know this is that I
just saw some other code that did that, and I was sure it was a bug
until I checked the standard (and the compiler's output). Given C's
nature and the number of things it does NOT guarantee, owing to
efficiency, it did not seem to me likely that the relationals would
guarantee this sort of thing... consider that (a != b) could be
implemented as (a - b) on some machines, and then compares wouldn't
return 1 or 0.

Sure, it turns out ANSI does guarantee 1 or 0, and that implementing !=
as just - wouldn't be allowed, but I didn't expect that.  I don't think
many experienced C programmers would (in fact, they might be less likely
to expect it than a novice!) so I think John is right to say it's
stylistically bad. It falls into the same categoiry as assuming the
compiler will get order of operations right for long baroque
unparentesized expressions using bitwise operators and things. Of course
it will, but It' stylistically bad not to defensively parenthesize
some things, both to make the meaning absolutely clear to the compiler
AND to other programmers who might later read the code.