Date: Thu, 9 May 2024 11:26:29 +0200
On 2024-05-09 at 11:01, Frederick Virchanza Gotham via Std-Proposals wrote:
> In the past I've heard of C/C++ compilers that have a char* that's
> bigger than an int* -- because the char pointer is a memory address
> plus a numerical offset (0 - 3) into a word. In the real world though
> I've never encountered such a compiler but I'll believe the rumour.
https://stackoverflow.com/questions/6971886/exotic-architectures-the-standards-committees-care-about
> The closest to this I've ever encountered is the Texas Instruments
> F28069 microcontroller whose smallest addressable unit of memory is 16
> bits. When they were designing the compiler for the F28069, they could
> have provided 8-Bit char's, and then a char* would need to be bigger
> than an int*, but instead they just decided to make CHAR_BIT == 16,
> meaning that all data pointers are the same size.
>
> So, If there is no extant C++23 compiler nowadays that has a char*
> that's bigger than any other data pointer, then would it make sense in
> the C++26 standard to say that all data pointers are intercompatible?
>
Why don't you just use static_assert(sizeof(int*) == sizeof(char*)) to
make sure your code only runs on systems where the assumption holds. If
that happens to be *everywhere*, that's good.
> In the past I've heard of C/C++ compilers that have a char* that's
> bigger than an int* -- because the char pointer is a memory address
> plus a numerical offset (0 - 3) into a word. In the real world though
> I've never encountered such a compiler but I'll believe the rumour.
https://stackoverflow.com/questions/6971886/exotic-architectures-the-standards-committees-care-about
> The closest to this I've ever encountered is the Texas Instruments
> F28069 microcontroller whose smallest addressable unit of memory is 16
> bits. When they were designing the compiler for the F28069, they could
> have provided 8-Bit char's, and then a char* would need to be bigger
> than an int*, but instead they just decided to make CHAR_BIT == 16,
> meaning that all data pointers are the same size.
>
> So, If there is no extant C++23 compiler nowadays that has a char*
> that's bigger than any other data pointer, then would it make sense in
> the C++26 standard to say that all data pointers are intercompatible?
>
Why don't you just use static_assert(sizeof(int*) == sizeof(char*)) to
make sure your code only runs on systems where the assumption holds. If
that happens to be *everywhere*, that's good.
Received on 2024-05-09 09:26:39