TITLE: on the sizes of pointers (Newsgroups: comp.lang.c++.moderated, 16 Mar 99) UNKNOWN1: >> >> 3. Are pointers always of the same size? Is it guaranteed that >> >> >> >> sizeof (char *) == sizeof (long *) >> >> >> >> and >> >> >> >> sizeof (char *) == sizeof (void *) UNKNOWN2: >> >All pointers to objects are the same size. CLAMAGE: Steve Clamage wrote: >> Not so. The standard explicitly recognizes that pointers to >> different kinds of data might have different sizes, by placing >> special requirements on void* and char*. SHIVA: Shiva writes: >Can you state which section in the standard says this. I tried >searching & couldn't come up with anything. This is important for me. CLAMAGE: Steve Clamage Section 3.9.2 says the representation is implementation-defined. It then makes a few special restrictions in paragraphs 3 and 4. Since it places size and alignment requirements only on certain categories of pointers, and doesn't say anything about other types of pointers, the implementation is free to make pointers to fundamental types any size, subject to the restrictions. For example, pointers to short, int, and double could all be different sizes or have different alignment requirements without violating any requirement. That is, you can't use static_cast to covert among those pointer types, and the results of reinterpret_cast are implementation-defined. If, for example, a short* was bigger than a double*, the implementation could just say that coverting a short* to a double* would lose some bits and might not result in a valid pointer. I don't know of an implemenation where pointers to different types report different sizes with "sizeof", but there might be some. I do know of systems where the representation of pointers to different types is different. On word-oriented machines, a char or a short is a partial word, and a pointer to a char or a short has a special format.