Sujet : Re: technology discussion → does the world need a "new" C ?
De : david.brown (at) *nospam* hesbynett.no (David Brown)
Groupes : comp.lang.cDate : 11. Jul 2024, 11:46:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6od5q$2djgq$3@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Mozilla Thunderbird
On 11/07/2024 04:51, Lawrence D'Oliveiro wrote:
On Wed, 10 Jul 2024 03:16:18 -0400, James Kuyper wrote:
On 7/9/24 20:57, Lawrence D'Oliveiro wrote:
>
On Sat, 6 Jul 2024 21:34:29 -0400, James Kuyper wrote:
>
On many platforms, if _Alignof(type) is less than the word size, then
a C pointer to that type is implemented as the combination of the
machine address of the correct word, combined with an offset within
that word of the first byte of that object.
>
Which is a terrific idea, except it cannot be carried to its logical
conclusion (addressing of arbitrarily-aligned dynamically-defined
bitfields) because of the requirement in the C spec that the size of a
“byte” be at least 8 bits.
>
I will grant you that I failed to mention the fact that this is a
feasible way of implementing C only on platforms with a word size of 16
bits or longer.
Don’t you think C needs a better way of handling bitfields than shift-and-
mask? Many architectures have bitfield instructions, but C cannot easily
make use of them without the ability to have arbitrarily-bit-aligned
pointers.
There are pros and cons of different ways to support bitfields in a language, and there are certainly aspects of C's bitfields that many people think are less than ideal.
But (good) C compilers have no problem using bitfield instructions on architectures that have these, so that at least is not an issue.