On Sat, May 18, 2013 at 11:55:48AM -0400, Zack Weinberg wrote: > There's nothing wrong with sizeof(long) == sizeof(int), but I assure > you that C89 does require sizeof(long) >= sizeof(void *) [more > precisely, that a valid value of type 'void*' can be cast to 'unsigned > long' and back without loss of information] provided also that the > memory space is flat. It is not itself a spelled-out requirement in > the standard, but it follows from two requirements which are > explicitly stated. First, 'size_t' is required to be able to represent > the size of any object; when the memory space is flat, this entails > that 'void*' can be cast to 'size_t' and back without loss of > information. Second, 'size_t' is required to be no larger than > 'unsigned long'. No, just no. It requires that sizeof(void *) can be cast to size_t. There are plenty of archs where the virtual address space is larger than any single object can be; lots and lots of old real-mode x86 compilers, for example. There are explicitly standards-conforming archs where pointer types can have sizes (a) dependent on the target type of the pointer and (b) larger than any integer type. For examples of weird pointers: http://c-faq.com/null/machexamp.html -- Andrea Shepard <andrea@xxxxxxxxxxxxxx> PGP fingerprint: 3611 95A4 0740 ED1B 7EA5 DF7E 4191 13D9 D0CF BDA5
Attachment:
pgp0EXgMPAGCG.pgp
Description: PGP signature
_______________________________________________ tor-dev mailing list tor-dev@xxxxxxxxxxxxxxxxxxxx https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-dev