3 ms·
C11: A pointer to void shall have the same representation and alignment requirements as a pointer to a character type. [48] <blah blah pointers to qual
by dzaima 3y ago
C11:
A pointer to void shall have the same representation and alignment requirements as a pointer to a character type. [48]
<blah blah pointers to qualified vs unqualified, structs, and unions also have the same representation between themselves>.
Pointers to other types need not have the same representation or alignment requirements.
[48]: The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and members of unions.
The thing I've heard for systems where e.g. an int* and char* aren't equal is where the "int*" is the "primary" pointer type, and a char* has to add back the would-be-leading-bits or something. Though as per the above quote, char* vs void* would be safe? Doesn't help anything other than char* though.
- erik_seaberg 3y agoThere used to be hardware that supported pointers to individual bits or complete words, rather than the eight-bit bytes we see today. https://en.wikipedia.org/wiki/Word_addressing https://en.wikipedia.org/wiki/Word_addressing