C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Make all data pointers intercompatible

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Thu, 9 May 2024 11:47:40 +0200
What do you mean by intercompatible? Same size, representation and alignment? Or conversion between any of them, even if the types are not interconvertible? For universal storing you can use a pointer to void (uintptr_t as an alternative is optional, and I do not find the guarantee in the standard, than it can be universally used). https://eel.is/c++draft/basic.compound#7 A pointer to cv void can be used to point to objects of unknown type. Such a pointer shall be able to hold any object pointer. An object of type “pointer to cv void” shall have the same representation and alignment requirements as an object of type “pointer to cv char”.   What other use cases do you have in mind? Perhaps making sure that structs have a certain expected length and certain offsets to members, regardless which pointers they also comprise? It would not be nice to have to store pointers to void, just to make sure of that.     -----Ursprüngliche Nachricht----- Von:Frederick Virchanza Gotham via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Do 09.05.2024 11:01 Betreff:[std-proposals] Make all data pointers intercompatible An:std-proposals <std-proposals_at_[hidden]>; CC:Frederick Virchanza Gotham <cauldwell.thomas_at_[hidden]>; 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. 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? Note that I'm not talking about code pointers here (i.e. I'm maintaining the distinction between data pointers and code pointers). -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-05-09 09:47:42