Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Jan 2004 11:27:10 -0800
From:      Jason Evans <jasone@canonware.com>
To:        Bruce Evans <bde@zeta.org.au>
Cc:        freebsd-standards@freebsd.org
Subject:   Re: standards/60772: _Bool and bool should be unsigned
Message-ID:  <20040101192710.GP74719@canonware.com>
In-Reply-To: <20040101153143.N7624@gamplex.bde.org>
References:  <20040101004057.19C541C5@canonware.com> <20040101153143.N7624@gamplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 01, 2004 at 03:52:08PM +1100, Bruce Evans wrote:
> The fake definition in FreeBSD-4.9 permits storing values between INT_MIN
> and INT_MAX, and changing it to unsigned so that it is limited to values
> between 0 and UINT_MAX isn't much of an improvment.

You're talking about the following problem, right?

	{
		int foo = 42;
		bool bar;

		/* This works okay. */
		bar = foo ? true : false;

		/* This breaks on 4.9. */
		bar = foo;
	}

This particular problem hasn't bitten me, but you're right that it's a
serious problem.

> I think the correct fix is to remove <stdbool.h> in RELENG_4, since it is
> impossible to implement it correctly.

This sounds reasonable to me, though doing so would potentially prevent
quite a number of ports from compiling.  Still, it seems better to refuse
to compile, than to willingly generate bad binaries.  This bug caused a
spectacular failure for some code I've been working on, but the resulting
bugs could easily have been much more subtle and gone unnoticed.

> Was there a defacto standard for it before C99?  It doesn't seem to have
> been very common -- it isn't in glibc-2.2.5 (which is 2 years old, but
> not as old as <stdnool.h> in FreeBSD).

I don't don't think there was a defacto standard for this.  The following
appears to be the original C99 addition document for stdbool.h:

	http://std.dkuug.dk/JTC1/SC22/WG14/www/docs/n815.htm

Jason



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040101192710.GP74719>