-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ben Pfaff <[EMAIL PROTECTED]> writes:
> I don't understand why ((size_t)-1) is considered C99 specific. You are correct. It is not C99 specific. I was quoting the C99 standard which Bruno referenced to be sure everyone was on the same page because I could not find the old post that Bruno said he used that argument. > Here is the equivalent paragraph from C90, numbered 3.2.1.2.(2) > and .(3): > [...elided...] > > Thus, ((size_t)-1) is also the maximum value of size_t in C90. This is true. Actually, all K&R C compiler implementations I have ever used let me use a cast of -1 to the an unsigned type to get the maximum value of the unsigned type, so that idiom has been around a long time. This included ones compliment computers (e.g., Cray Y-MP) as well as the more common twos compliment computers. The real argument was the previous SIZE_MAX definition of (~(size_t)0) which may NOT be the maximum value of a size_t if the width of an size_t is narrower than int. Bruno's alternative was to use ((size_t)~(size_t)0) which also will be the maximum value of a size_t. As Bruno appears to prefer his idiom to one that plays games with negative numbers in the definition of an unsigned quantity and both have equivalent value, he committed the one he liked as he is the maintainer for stdint_.h ... simple. I hope this clears up your confusion. Enjoy! -- Mark -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (FreeBSD) iD8DBQFDw2ElCg7APGsDnFERAvy6AJkBKwON8UOO7KHU2DptVViWRwSxSgCeLNAj udhJ88j1VZeZTy6iCEucFE4= =xket -----END PGP SIGNATURE----- _______________________________________________ bug-gnulib mailing list bug-gnulib@gnu.org http://lists.gnu.org/mailman/listinfo/bug-gnulib