On 4/6/25 03:00, Florian Weimer wrote:
* Sandra Loosemore:

@@ -13698,6 +13699,17 @@ Forward-declaring an incomplete enum type without an 
explicit
  underlying type is supported as an extension in all GNU C dialects,
  but is not supported at all in GNU C++.
+@node Boolean Type
+@subsection Support for the @code{_Bool} Type
+@cindex boolean type
+@cindex @code{_Bool} keyword
+
+The C99 standard added @code{_Bool} as a C language keyword naming the
+boolean type.  As an extension, GNU C also recognizes @code{_Bool} in
+C90 mode as well as with @option{-std=c99} and later.

I think with C23, _Bool is again a GNU extension.

I checked this before writing that text. The draft document of the C23 standard I've been using as a reference (N3096) lists _Bool as an alternate spelling for bool in section 6.4.1, "Keywords". So it's not an extension, it's still part of the language, although a footnote says it's an "obsolescent feature".

+GNU C++ does not support the @code{_Bool} keyword.

Maybe mention that including <stdbool.h> defines _Bool as a macro?

Hmmm, OK. I'd missed that in my experimenting to find out what worked with which -std= options, and grepping the C++ front end code for _Bool.

I've pushed the attached patch with clarifications for both of these things.

-Sandra
From 05ceea81506c39d2b67cd70c6abc73cb3d03abd1 Mon Sep 17 00:00:00 2001
From: Sandra Loosemore <sloosem...@baylibre.com>
Date: Sun, 6 Apr 2025 16:03:48 +0000
Subject: [COMMITTED] Doc: Further clarify support for _Bool type

gcc/ChangeLog
	* doc/extend.texi (Boolean Type): Further clarify support for
	_Bool in C23 and C++.
---
 gcc/doc/extend.texi | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 16ad83fc510..ae3357f83bf 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13814,7 +13814,13 @@ The C99 standard added @code{_Bool} as a C language keyword naming the
 boolean type.  As an extension, GNU C also recognizes @code{_Bool} in
 C90 mode as well as with @option{-std=c99} and later.
 
-GNU C++ does not support the @code{_Bool} keyword.
+C23 added @code{bool} as the preferred name of the boolean type, but
+@code{_Bool} also remains a standard keyword in the language and is
+supported as such by GCC with @option{-std=c23}.
+
+GNU C++ does not support @code{_Bool} as a keyword, but including
+@code{<stdbool.h>} defines it as a macro in terms of standard C++'s
+@code{bool} type.
 
 @node Variadic Macros
 @subsection Macros with a Variable Number of Arguments.
-- 
2.34.1

Reply via email to