From myself@cae88-102-101.sc.rr.com  Sat Nov 18 00:50:24 2000
Return-Path: <myself@cae88-102-101.sc.rr.com>
Received: from cae88-102-101.sc.rr.com (unknown [24.88.102.101])
	by hub.freebsd.org (Postfix) with ESMTP id E3CB037B479
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Nov 2000 00:50:23 -0800 (PST)
Received: (from myself@localhost)
	by cae88-102-101.sc.rr.com (8.11.1/8.9.3) id eAI8oOt50089;
	Sat, 18 Nov 2000 03:50:24 -0500 (EST)
	(envelope-from myself)
Message-Id: <200011180850.eAI8oOt50089@cae88-102-101.sc.rr.com>
Date: Sat, 18 Nov 2000 03:50:24 -0500 (EST)
From: Donald.J.Maddox@cae88-102-101.sc.rr.com
Sender: myself@cae88-102-101.sc.rr.com
Reply-To: dmaddox@sc.rr.com
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: <stdbool.h> broken, needs repair
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         22936
>Category:       misc
>Synopsis:       /usr/include/stdbool.h defines _bool twice when included by gcc.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    asmodai
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Nov 18 01:00:00 PST 2000
>Closed-Date:    Mon Jan 1 15:15:56 PST 2001
>Last-Modified:  Mon Jan 01 15:16:14 PST 2001
>Originator:     Donald J. Maddox
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
System: FreeBSD cae88-102-101.sc.rr.com 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Wed Nov 15 00:22:26 EST 2000 root@cae88-102-101.sc.rr.com:/usr/src/sys/compile/RHIANNON i386

>Description:
	The header file <stdbool.h> contains a defective
conditional that breaks several ports.  Any code that includes
<stdbool.h> will break if compiled by gcc...  Example:

#include <stdbool.h>

int main()
{
	return(0);
}

$ cc test.c
In file included from test.c:1:
/usr/include/stdbool.h:51: conflicting types for `_Bool'
/usr/include/stdbool.h:38: previous declaration of `_Bool'

>How-To-Repeat:
	See above :)
>Fix:

--- /usr/src/include/stdbool.h	Sat Sep 16 03:28:44 2000
+++ stdbool.h.new	Sat Nov 18 03:23:55 2000
@@ -31,11 +31,15 @@
 #ifndef	_STDBOOL_H_
 #define	_STDBOOL_H_	
 
+#if __STDC_VERSION__ < 199901L
+typedef int	_Bool;		/* not built into pre-C99 compilers */
+#else
 /* `_Bool' type must promote to `int' or `unsigned int' */
 typedef enum {
 	false = 0,
 	true = 1
 } _Bool;
+#endif
 
 /* And those constants must also be available as macros */
 #define	false	false
@@ -46,9 +50,5 @@
 
 /* Inform that everything is fine */
 #define __bool_true_false_are_defined 1
-
-#if __STDC_VERSION__ < 199901L
-typedef int	_Bool;		/* not built into pre-C99 compilers */
-#endif
 
 #endif /* _STDBOOL_H_ */

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: dmaddox@sc.rr.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: misc/22936: <stdbool.h> broken, needs repair
Date: Sun, 19 Nov 2000 04:18:45 +1100 (EST)

 On Sat, 18 Nov 2000 Donald.J.Maddox@cae88-102-101.sc.rr.com wrote:
 
 > >Description:
 > 	The header file <stdbool.h> contains a defective
 > conditional that breaks several ports.  Any code that includes
 > <stdbool.h> will break if compiled by gcc...  Example:
 
 Much more is broken than that, at least according to a C99 draft (n869).
 1) _Bool is a first class type (like int), so it can't be declared as
    a typedef (unless compiler magic supports such a declaration).
 2) `true' and `false' are supposed to be usable in cpp expressions, so
    they can't be declared as enum values.
 3) The definitions of `false' and `true' as themself don't work in K&R
    mode.  This is not a serious bug, since K&R code shouldn't include
    <stdbool.h>.
 4) Support for the Standard C (c99) _Bool is premature, since gcc doesn't
    support _Bool as a first class type.
 
 <stdbool.h> is essentially a compatibility hack for pre-c99 compilers.
 The current version seems to be based on the gcc version.  Both versions
 will break when gcc actually supports _Bool.
 
 Here is a version compatible with the C99 draft and K&R:
 
 ---
 #define	__bool_true_false_are_defined	1
 #define	false	0
 #define	true	1
 
 #define	bool	_Bool
 #if __STDC_VERSION__ < 199901L
 typedef	int	_Bool;
 #endif
 ---
 
 Bruce
 
 

From: "Donald J . Maddox" <dmaddox@sc.rr.com>
To: Bruce Evans <bde@zeta.org.au>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: misc/22936: <stdbool.h> broken, needs repair
Date: Sat, 18 Nov 2000 13:39:09 -0500

 Thanks.  Are you going to commit your fix and close the PR?
 
 On Sun, Nov 19, 2000 at 04:18:45AM +1100, Bruce Evans wrote:
 > On Sat, 18 Nov 2000 Donald.J.Maddox@cae88-102-101.sc.rr.com wrote:
 > 
 > > >Description:
 > > 	The header file <stdbool.h> contains a defective
 > > conditional that breaks several ports.  Any code that includes
 > > <stdbool.h> will break if compiled by gcc...  Example:
 > 
 > Much more is broken than that, at least according to a C99 draft (n869).
 > 1) _Bool is a first class type (like int), so it can't be declared as
 >    a typedef (unless compiler magic supports such a declaration).
 > 2) `true' and `false' are supposed to be usable in cpp expressions, so
 >    they can't be declared as enum values.
 > 3) The definitions of `false' and `true' as themself don't work in K&R
 >    mode.  This is not a serious bug, since K&R code shouldn't include
 >    <stdbool.h>.
 > 4) Support for the Standard C (c99) _Bool is premature, since gcc doesn't
 >    support _Bool as a first class type.
 > 
 > <stdbool.h> is essentially a compatibility hack for pre-c99 compilers.
 > The current version seems to be based on the gcc version.  Both versions
 > will break when gcc actually supports _Bool.
 > 
 > Here is a version compatible with the C99 draft and K&R:
 > 
 > ---
 > #define	__bool_true_false_are_defined	1
 > #define	false	0
 > #define	true	1
 > 
 > #define	bool	_Bool
 > #if __STDC_VERSION__ < 199901L
 > typedef	int	_Bool;
 > #endif
 > ---
 > 
 > Bruce
 > 
 

From: Bruce Evans <bde@zeta.org.au>
To: "Donald J . Maddox" <dmaddox@sc.rr.com>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: misc/22936: <stdbool.h> broken, needs repair
Date: Sun, 19 Nov 2000 09:32:01 +1100 (EST)

 On Sat, 18 Nov 2000, Donald J . Maddox wrote:
 
 > Thanks.  Are you going to commit your fix and close the PR?
 
 I hope the committer of <stdbool.h> wll fix it.  I didn't get around
 to reviewing it before it was committed :(.
 
 Bruce
 
 
Responsible-Changed-From-To: freebsd-bugs->asmodai 
Responsible-Changed-By: sobomax 
Responsible-Changed-When: Tue Nov 21 09:35:32 PST 2000 
Responsible-Changed-Why:  
Asmo brought it, so he'll fix it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=22936 
State-Changed-From-To: open->suspended 
State-Changed-By: asmodai 
State-Changed-When: Wed Nov 29 06:41:18 PST 2000 
State-Changed-Why:  
Committed a fix per bde's suggestions. 

Put on suspend until sobomax is happy. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=22936 

From: "Donald J. Maddox" <dmaddox@sc.rr.com>
To: freebsd-gnats-submit@FreeBSD.org, dmaddox@sc.rr.com
Cc:  
Subject: Re: misc/22936: /usr/include/stdbool.h defines _bool twice when included 
 by gcc.
Date: Mon, 01 Jan 2001 17:44:12 -0500

 This PR is suspended 'until sobomax is happy'...
 
 Is he happy yet? :)
 
State-Changed-From-To: suspended->closed 
State-Changed-By: sobomax 
State-Changed-When: Mon Jan 1 15:15:56 PST 2001 
State-Changed-Why:  
I'm happy now, whatever it means!!! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=22936 
>Unformatted:
