Signed word lengths and indexes

"Jérôme M. Berger" jeberger at free.fr
Thu Jun 17 12:06:20 PDT 2010


Kagamin wrote:
> Jérôme M. Berger Wrote:
> 
>> #include <assert.h>
>> #include <stdio.h>
>>
>> int main (int argc, char** argv) {
>>    char*        data   = argv[0];  /* Just to get a valid pointer */
>>    unsigned int offset = 3;
>>
>>    printf ("Original: %p\n", data);
>>
>>    data += offset;
>>    printf ("+3      : %p\n", data);
>>
>>    data += -offset;
>>    printf ("-3      : %p\n", data);
>>
>>    assert (data == argv[0]);    /* Works on 32-bit systems, fails on 64-bit */
>>
>>    return 0;
>> }
>>
> Yo, dude!
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=97545

	Yes, I know. I was pointing out to Walter a real life example of
code that works on 32-bit systems but not on 64-bit systems because
of signedness issues. That was in answer to Walter saying: "I
thought most 64 bit C compilers were specifically designed to avoid
this problem."

		Jerome
-- 
mailto:jeberger at free.fr
http://jeberger.free.fr
Jabber: jeberger at jabber.fr

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100617/b63ea57c/attachment.pgp>


More information about the Digitalmars-d mailing list