Date: Thu, 13 Oct 2022 00:25:20 +0100
This email isn't actually a proposal for the C++ Standard, however I
think I should post it here for the committee to see (I've posted it
to comp.lang.c++ too).
Since I started programming in C/C++ back in the early 2000's, I've
never encountered a compiler with CHAR_BIT anything other than 8. I
heard about some fancy supercomputers that had the following setup:
1 == sizeof(char) == sizeof(int) == sizeof(short) == sizeof(long)
== sizeof(long long)
and so CHAR_BIT would be 64, but I've never walked within a mile of
such a computer.
Well just now in the past 20 minutes, I was trying to get C++ code for
the 'base58' algorithm to compile for the Texas Instruments F2809
microcontroller using the 'cl2000' compiler.
At first I was puzzled as to why 'sizeof(long)' was coming back as 2.
Of course my first assumption here was that 'long' was 16-Bit (even
though the Standard says that a 'long' must be at least 32-Bit). So I
figured that this compiler was just non-standard-compliant on a few
issues.
After a little messing around, I realised that CHAR_BIT is 16.
I looked through the compiler manual and found this paragraph:
"By ANSI/ISO C definition, the sizeof operator yields the number of
bytes required to store an object. ANSI/ISO further stipulates that
when sizeof is applied to char, the result is 1. Since the TMS320C28x
char is 16 bits (to make it separately addressable), a byte is also 16
bits. This yields results you may not expect; for example, size of
(int) = = 1 (not 2). TMS320C28x bytes and words are equivalent (16
bits). To access data in increments of 8 bits, use the __byte() and
__mov_byte() intrinsics described in Section 7.6"
So there you go: There are C++ compilers in use today in the year 2022
with CHAR_BIT something other than 8.
I've noticed that as the C++ Standard has evolved, freedoms have been
taken away from compiler writers, for example negative numbers now
have to be two's complement, whereas in the past they had the choice
of sign-magnitude and one's.
So if the committee is thinking about mandating CHAR_BIT to be 8, well
I want you all to know that there's a microcontroller in use today in
they year 2022 that has CHAR_BIT == 16.
think I should post it here for the committee to see (I've posted it
to comp.lang.c++ too).
Since I started programming in C/C++ back in the early 2000's, I've
never encountered a compiler with CHAR_BIT anything other than 8. I
heard about some fancy supercomputers that had the following setup:
1 == sizeof(char) == sizeof(int) == sizeof(short) == sizeof(long)
== sizeof(long long)
and so CHAR_BIT would be 64, but I've never walked within a mile of
such a computer.
Well just now in the past 20 minutes, I was trying to get C++ code for
the 'base58' algorithm to compile for the Texas Instruments F2809
microcontroller using the 'cl2000' compiler.
At first I was puzzled as to why 'sizeof(long)' was coming back as 2.
Of course my first assumption here was that 'long' was 16-Bit (even
though the Standard says that a 'long' must be at least 32-Bit). So I
figured that this compiler was just non-standard-compliant on a few
issues.
After a little messing around, I realised that CHAR_BIT is 16.
I looked through the compiler manual and found this paragraph:
"By ANSI/ISO C definition, the sizeof operator yields the number of
bytes required to store an object. ANSI/ISO further stipulates that
when sizeof is applied to char, the result is 1. Since the TMS320C28x
char is 16 bits (to make it separately addressable), a byte is also 16
bits. This yields results you may not expect; for example, size of
(int) = = 1 (not 2). TMS320C28x bytes and words are equivalent (16
bits). To access data in increments of 8 bits, use the __byte() and
__mov_byte() intrinsics described in Section 7.6"
So there you go: There are C++ compilers in use today in the year 2022
with CHAR_BIT something other than 8.
I've noticed that as the C++ Standard has evolved, freedoms have been
taken away from compiler writers, for example negative numbers now
have to be two's complement, whereas in the past they had the choice
of sign-magnitude and one's.
So if the committee is thinking about mandating CHAR_BIT to be 8, well
I want you all to know that there's a microcontroller in use today in
they year 2022 that has CHAR_BIT == 16.
Received on 2022-10-12 23:25:32