From owner-freebsd-standards@FreeBSD.ORG Sun Jan 4 05:40:17 2004 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1BF0D16A4CE for ; Sun, 4 Jan 2004 05:40:17 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 196E143D4C for ; Sun, 4 Jan 2004 05:40:16 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i04DeFFR031543 for ; Sun, 4 Jan 2004 05:40:15 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i04DeFaw031541; Sun, 4 Jan 2004 05:40:15 -0800 (PST) (envelope-from gnats) Date: Sun, 4 Jan 2004 05:40:15 -0800 (PST) Message-Id: <200401041340.i04DeFaw031541@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Bruce Evans Subject: Re: standards/60772: _Bool and bool should be unsigned X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Bruce Evans List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 04 Jan 2004 13:40:17 -0000 The following reply was made to PR standards/60772; it has been noted by GNATS. From: Bruce Evans To: Jonathan Lennox Cc: freebsd-gnats-submit@freebsd.org Subject: Re: standards/60772: _Bool and bool should be unsigned Date: Mon, 5 Jan 2004 00:39:01 +1100 (EST) On Fri, 2 Jan 2004, Jonathan Lennox wrote: > Notice also PR bin/48958 -- in RELENG_4, the 'bool' type isn't > binary-compatible between C and C++. Another reason to drop it from > RELENG_4. Hmm. The absence of stdbool.h in glibc-2.2.5 is mostly likely just because is part of gcc (glibc doesn't have stddef.h either). We have gcc's stdbool.h in RELENG_4 but don't install it. It uses: % typedef enum % { % false = 0, % true = 1 % } bool; This causes slightly different problems than typedef "int bool". I noticed the following: - non-problem: the enum is apparently implemented as an unsigned int, so assignments of "true" to a bitfield of width 1 work right. - bitfields can't have type enum for C compilers (according to TenDRA), so the above is very unportable. - bool can hold values other than true and false. So can bool bitfields of width larger than 1. - same binary compability problem as "int bool". Enums apparently always have the same size and alignment as int in gcc, presumably because enums are too much like ints to be very useful. I think we can't just unsupport it, since gcc has it. Approx. 20 ports reference stdbool.h in their patches. Bruce