C++ Logo


Advanced search

Re: Restrict possible values of CHAR_BIT

From: Thiago Macieira <thiago_at_[hidden]>
Date: Thu, 24 Oct 2019 14:33:44 -0700
On Thursday, 24 October 2019 13:52:37 PDT Arthur O'Dwyer via Std-Proposals
> Yes, but "a 14-bit type exists" is not the same thing as "CHAR_BIT==14". I
> would be as surprised as Lyberta (and perhaps more so) if any C++ compiler
> in the world supported "CHAR_BIT==14".

The problem is that it must, unless those extra 6 bits can't be accessed from
C++ in *any* type. Remember memcpy & memset: they need to be able to see all
bits in order to copy or set them.

But this is about memory, not register size. Let's just make sure we're
talking about the right thing here.

> However, I agree with Tom that this proposal is not motivated. Personally I
> think it'd be just as silly to have CHAR_BIT==16 or CHAR_BIT==32 as to have
> CHAR_BIT==9 or CHAR_BIT==24. If we're trying to get C++ to fall in line
> with what "everybody knows," then the way to do that is to mandate
> CHAR_BIT==8, not to keep the current situation of "CHAR_BIT==I don't know,
> ask your vendor" but also put odd restrictions on the vendor's choice.

We do have a restriction that CHAR_BIT >= 8.

> Lyberta, did your survey turn up any C++ implementations where CHAR_BIT !=
> 8? If so, what version of C++ were they — C++03, 11, 14, 17?

Please expand that to C implementations too. Restricting to only platforms
that currently have C++ means C++ could not expand to ones where C exists.

Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2019-10-24 16:36:01