From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7b65fc33a05f24b6 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad.newshosting.com!newshosting.com!198.186.194.250.MISMATCH!news-xxxfer.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Fri, 05 Dec 2008 06:51:53 -0500 From: "Peter C. Chapin" User-Agent: Thunderbird 2.0.0.18 (Windows/20081105) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: A curiosity... References: <0f009ce8-0f50-4b85-9368-0d0c68f42da1@w34g2000yqm.googlegroups.com> <396044ea-4c37-4923-b989-eb4af2202bd3@o2g2000yqd.googlegroups.com> <87r64naw36.fsf@willow.rfc1149.net> In-Reply-To: <87r64naw36.fsf@willow.rfc1149.net> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <493915da$0$21338$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: e3ca3201.news.sover.net X-Trace: DXC=6AS?]6oE24>SoQbMV>2=O5K6_LM2JZB_3cG[J4?PLBK:3?@`i3kGa5;`Jo46GaG;l8] Samuel Tardieu wrote: > Nah, this is a FUD. If you want to use an integer type in C which is > compatible with addresses, you should use "size_t" explicitely, not > any other integer type (though I know of no architecture where > "unsigned long" is not the same as "size_t" even though this is > allowed). Section 17.18.1.4 of the C99 standard defines the type intptr_t and uintptr_t as follows: The following type designates a signed integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: intptr_t The following type designates an unsigned integer type with the property that any valid pointer to void can be converted to this type, then converted back to pointer to void, and the result will compare equal to the original pointer: uintptr_t These types are optional. These types were introduced, I expect, because so many people feel a need to convert pointers into integers and back again, yet the older C standard did not provide a portable way of doing that. Note, however, that these types are optional. Note also that the OP's example actually requires the opposite of what is provided here. The OP's example depends on converting an integer to a pointer and back again without loss of information... the types above might not support that (they might be too long to fit into a pointer). Peter