[PATCH] c++: Stop defining true, false and bool as macros in <stdbool.h>

Nathan Sidwell nathan@acm.org
Wed Sep 2 19:31:52 GMT 2020


On 9/2/20 3:13 PM, Jonathan Wakely wrote:
> Since r216679 these macros have only been defined in C++98 mode, rather
> than all modes. That is permitted as a GNU extension because that header
> doesn't exist in the C++ standard until C++11, so we can make it do
> whatever we want for C++98. But as discussed in the PR c++/60304
> comments, these macros shouldn't ever be defined for C++.
> 
> This patch removes the macro definitions for C++98 too.
> 
> The new test already passed for C++98 (and the conversion is ill-formed
> in C++11 and later) so this new test is arguably unnecessary.
> 
> gcc/ChangeLog:
> 
> 	PR c++/60304
> 	* ginclude/stdbool.h (bool, false, true): Never define for C++.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR c++/60304
> 	* g++.dg/warn/Wconversion-null-5.C: New test.
> 
> 
> Back in 2012 Gerald argued that we should keep these macros in case
> there is code depending on them. We've not been defining them in C++11
> and later modes (including our default -std=gnu++14) for nearly six
> years now (GCC 5.1 shipped with the change).  I'm not aware of any
> reports of problems. I think it's time to stop defining them at all.
> 
> Bootstrapped and tested on powerpc64le-linux, OK for trunk?

seems reasonable, thanks



-- 
Nathan Sidwell


More information about the Gcc-patches mailing list