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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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: g2news1.google.com!news3.google.com!feeder.news-service.com!87.106.137.111.MISMATCH!feeder1.news.weretis.net!newsfeeder.dynfx.net!weretis.net!news.motzarella.org!motzarella.org!news.motzarella.org!not-for-mail From: Keith Thompson Newsgroups: comp.lang.ada Subject: Re: A curiosity... Date: Fri, 05 Dec 2008 08:37:22 -0800 Organization: None to speak of Message-ID: References: <0f009ce8-0f50-4b85-9368-0d0c68f42da1@w34g2000yqm.googlegroups.com> <396044ea-4c37-4923-b989-eb4af2202bd3@o2g2000yqd.googlegroups.com> <87r64naw36.fsf@willow.rfc1149.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.motzarella.org U2FsdGVkX18ZkHG9r5W2q30kcdH1HdnejXDvTqbpQco2epvJwnTVXTsXKuf4o/Sh0nfHg2b223w4Td0STeWdQrJuUgrmHK93DeshMboj95qXGThKPhsIoF5/HocuD4J601RBbzXNfvU= X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Fri, 5 Dec 2008 16:37:23 +0000 (UTC) X-Auth-Sender: U2FsdGVkX18MD1IM4pQ+Qqk/tspiljMZ Cancel-Lock: sha1:fWud2ocrwQ0ruihlymljBwtC1I8= sha1:m52/NyJb8dVodyNownmkspW6/wk= User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (gnu/linux) Xref: g2news1.google.com comp.lang.ada:2893 Date: 2008-12-05T08:37:22-08:00 List-Id: Samuel Tardieu writes: >>>>>> "Ludovic" == Ludovic Brenta writes: > Ludovic> And I think this rule is responsible for the "limitation" > Ludovic> that all current processor architectures use addresses which > Ludovic> are the same size as integers. Before the advent of C, > Ludovic> address size and word size were not necessarily the same; now > Ludovic> they always are, and that's *only* for compatibility with C. > > Certainly not. For example, on a x86_64 Linux machine with GCC, you > can try the following snippet (untested): > > #include > int main() > { > printf("integer size is %d, pointer size is %d\n", > sizeof(int), sizeof(void*)); > return 0; > } > > You should get respectively 4 and 8. [...] You get undefined behavior, since "%d" expects an argument of type int and you're giving it an argument of type size_t. And on the system in question, it's very likely that size_t is bigger than int, so this could cause real problems. printf("integer size is %lu, pointer size is %lu\n", (unsigned long)sizeof(int), (unsigned long)sizeof(void*)); or, in C99: printf("integer size is %zu, pointer size is %zu\n", sizeof(int), sizeof(void*)); -- Keith Thompson (The_Other_Keith) kst-u@mib.org Nokia "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"