Date: Sun, 26 Jan 2025 18:11:40 -0600
> It's possible if the compiler hides it from the programmer. For instance
if CHAR_BIT==8, and if the CPU instructions deal with 16-Bit operands, then
you can have:
>
> CHAR_BIT == 8
> sizeof(int*) == 2
> sizeof(char*) == 3
All the language cares about is that you can in fact address every byte of
memory. From a language perspective, if CHAR_BIT == 8 then the smallest
addressable unit of memory is 8 bits irrespective of hardware details.
Between https://eel.is/c++draft/basic.memobj#intro.memory-1 and
https://eel.is/c++draft/basic.compound#7 and the fact struct Frog; Frog*
ptr1 = nullptr; Frog* foo(); Frog* ptr2 = foo(); has to work I think it's
sufficiently covered by the standard that all pointers to non-fundamental
objects are the same size (or at least compatible in some way to make
everything here work). Even if you had a system where sizeof(char*) == 3
and sizeof(int*) == 2 you would know sizeof(void*) >= 3.
Cheers,
Jeremy
On Sun, Jan 26, 2025 at 5:42 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> On Sun, Jan 26, 2025 at 11:17 PM Jeremy Rifkin wrote:
> >
> > > For example on a system where CHAR_BIT==8 but the smallest addressable
> unit of memory is 16 bits
> >
> > That's not possible https://eel.is/c++draft/basic.memobj#intro.memory-1
>
>
> It's possible if the compiler hides it from the programmer. For
> instance if CHAR_BIT==8, and if the CPU instructions deal with 16-Bit
> operands, then you can have:
>
> CHAR_BIT == 8
> sizeof(int*) == 2
> sizeof(char*) == 3
>
> An int* is a 16-Bit number representing a memory address.
> A char* is a 16-Bit number representing a memory address, with an
> extra byte to indicate the offset.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
if CHAR_BIT==8, and if the CPU instructions deal with 16-Bit operands, then
you can have:
>
> CHAR_BIT == 8
> sizeof(int*) == 2
> sizeof(char*) == 3
All the language cares about is that you can in fact address every byte of
memory. From a language perspective, if CHAR_BIT == 8 then the smallest
addressable unit of memory is 8 bits irrespective of hardware details.
Between https://eel.is/c++draft/basic.memobj#intro.memory-1 and
https://eel.is/c++draft/basic.compound#7 and the fact struct Frog; Frog*
ptr1 = nullptr; Frog* foo(); Frog* ptr2 = foo(); has to work I think it's
sufficiently covered by the standard that all pointers to non-fundamental
objects are the same size (or at least compatible in some way to make
everything here work). Even if you had a system where sizeof(char*) == 3
and sizeof(int*) == 2 you would know sizeof(void*) >= 3.
Cheers,
Jeremy
On Sun, Jan 26, 2025 at 5:42 PM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> On Sun, Jan 26, 2025 at 11:17 PM Jeremy Rifkin wrote:
> >
> > > For example on a system where CHAR_BIT==8 but the smallest addressable
> unit of memory is 16 bits
> >
> > That's not possible https://eel.is/c++draft/basic.memobj#intro.memory-1
>
>
> It's possible if the compiler hides it from the programmer. For
> instance if CHAR_BIT==8, and if the CPU instructions deal with 16-Bit
> operands, then you can have:
>
> CHAR_BIT == 8
> sizeof(int*) == 2
> sizeof(char*) == 3
>
> An int* is a 16-Bit number representing a memory address.
> A char* is a 16-Bit number representing a memory address, with an
> extra byte to indicate the offset.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-01-27 00:11:57