Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: Is bool no longer a primitive data type of C/C++ ?
Date: Sun, 29 Nov 2020 17:42:18 -0800
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <86mtyzpqmd.fsf@linuxsc.com>
References: <875z6nu10d.fsf@bsb.me.uk> <83458da8-c4fa-4a7f-acea-bb04b9d8ee3en@googlegroups.com> <-oidnSk6-K2g_D3CnZ2dnUU7-e3NnZ2d@giganews.com> <21562d54-68c2-4a39-99ad-ada14cce43f8n@googlegroups.com> <868sakr34t.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="8d063415095a95402c287fb3f3d379d0"; logging-data="12958"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KMZ+ILNvJ5qAYIWU3Gb8wYeRioqXfjvs="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:8Yi9kdq5Sby3oGkp46LO8mr5YsQ= sha1:M7FEVx+en/fpY4aoCUheXz0iUFI=
Xref: csiph.com comp.lang.c:156818
Richard Damon writes:
>> On 29/11/2020 09:14, Tim Rentsch wrote:
>>
>>> Is there anything in the C standard that would preclude the
>>> type 'enum Boolean{false, true}' from having a compatible
>>> type of _Bool? I looked but didn't see anything.
>
> Could the implementation define an extended integer type that had
> sizeof = sizeof bool, and only 1 value bit and the rest be padding
> (with a non-zero value of the padding being a trap representation)
> and then make the enum be compatible with that type?
The compatible type chosen for an enum may be an extended integer
type.
AFAICS an implementation may offer a pair of extended integer
types (one signed, one unsigned) with a width of one and a size
of any integral power of two bytes (which sizeof _Bool certainly
satisfies). The integer conversion rank of those extended types
would be unusual in that it would be less than the integer
conversion rank of _Bool, but the Standard doesn't preclude that
AFAICT.
Thus it appears that the answer to your question is Yes.