3 ms·
It would presumably involve a new type that didn't exist in the current ABI. Those pointers would stay the same, and the new (twice as big) pointers would be us
by rkangel 7y ago
It would presumably involve a new type that didn't exist in the current ABI. Those pointers would stay the same, and the new (twice as big) pointers would be used for the array feature.
- professoretc 7y agoThe point of uintptr_t is that it's an integer type to which any pointer type can be cast. If you introduce a new class of pointers which are not compatible with uintptr_t, then suddenly you have pointers which are not pointers.
- kazinator 7y agoYou would be shocked by this language called C++ which is highly compatible with C and has "pointer to member" types that don't fit into a uintptr_t. (Spoiler: no, there is no uintptr2_t).
- loeg 7y agoDitto uintmax_t. We do not want a uintmax2_t.
- _kst_ 7y agoNo, uintptr_t is an integer type to which any object pointer type can be converted without loss of information. (Strictly speaking, the guarantee is for conversion to and from void*.) And if an implementation doesn't have a sufficiently wide integer type, it won't define uintptr_t. (Likewise for intptr_t the signed equivalent.) There's no guarantee that a function pointer type can be converted to uintptr_t without loss of information. C currently has two kinds of pointer types: object pointer types and function pointer types. "Fat pointers" could be a third. And since a fat pointer would internally be similar to a structure, converting it to or from an integer doesn't make a whole lot of sense. (If you want to examine the representation, you can use memcpy to copy it to an array of unsigned char.)
- saagarjha 7y agoNote that POSIX requires that object pointers and function pointers are the same for dlsym.
- loeg 7y agoSurely you're not arguing that a bounded array is in fact a function rather than an object? The distinction between function and object pointers exists for Harvard architecture computers, which sort of exist (old Atmel AVR before they adopted ARM), but are not dominant.
- kazinator 7y agoOn a given platform, the fat pointer type could have an easily defined ABI expressible in C90 declarations (whose ABI is then deducible accordingly). For instance, complex double numbers can have an ABI which says that they look like struct { double re, im; };