I\'m arguing with my boss about this. They say \"Yes they can be different.\"
Is it possible that sizeof(T*) != sizeof(const T*)
for a type T
?<
Hmm, this is highly esoterical, but I'm thinking that theoretically there could be an architecture which has, say, 256 bytes of RAM in address 0 and, say, some kilobytes of ROM in higher addresses. And there could be a compiler that would create a 8-bit pointer for int *i
because 8 bits is enough to hold the address of any object in the highly limited RAM area and any mutable object of course is implicitly known to be in the RAM area. Pointers of type const int *i
would need 16 bits so that they could point to any location in the address space. The 8-bit pointer int *i
is castable to a 16-bit pointer const int *i
(but not vice versa) so the castability requirement of C standard would be satisfied.
But if there's such an architecture in existense, I'd sure like to see it (but not write code for it) :)