about summary refs log tree commit diff
path: root/library/std/src/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorthe8472 <the8472@users.noreply.github.com>2021-09-21 22:54:04 +0200
committerGitHub <noreply@github.com>2021-09-21 22:54:04 +0200
commit8a6e9cf07471672f75a24047b48131a547355106 (patch)
treee4d27ee3f06188f57298eecc052f0d81e4b5c807 /library/std/src/sys/unix/stack_overflow.rs
parentecfdadcef9070951adf10e116ef768e7846b7e5c (diff)
parent23c608f3a1b0cf09344f0e356610e59d8ee581ac (diff)
downloadrust-8a6e9cf07471672f75a24047b48131a547355106.tar.gz
rust-8a6e9cf07471672f75a24047b48131a547355106.zip
Rollup merge of #89114 - dequbed:c-char, r=yaahc
Fixes a technicality regarding the size of C's `char` type

Specifically, ISO/IEC 9899:2018 — better known as "C18" — (and at least
C11, C99 and C89) do not specify the size of `byte` in bits.
Section 3.6 defines "byte" as "addressable unit of data storage" while
section 6.2.5 ("Types") only defines "char" as "large enough to store
any member of the basic execution set" giving it a lower bound of 7 bit
(since there are 96 characters in the basic execution set).
With section 6.5.3.4 paragraph 4 "When sizeof is applied to an operant
that has type char […] the result is 1" you could read this as the size
of `char` in bits being defined as exactly the same as the number of
bits in a byte but it's also valid to read that as an exception.

In general implementations take `char` as the smallest unit of
addressable memory, which for modern byte-addressed architectures is
overwhelmingly 8 bits to the point of this convention being completely
cemented into just about all of our software.

So is any of this actually relevant at all? I hope not. I sincerely hope
that this never, ever comes up.
But if for some reason a poor rustacean is having to interface with C
code running on a Cray X1 that in 2003 is still doing word-addressed
memory with 64-bit chars and they trust the docs here blindly it will
blow up in her face. And I'll be truly sorry for her to have to deal
with … all of that.
Diffstat (limited to 'library/std/src/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions