delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/08/15:46:01

Date: Tue, 8 Sep 1998 21:43:52 +0200 (MET DST)
From: Elliott Oti <E DOT U DOT Oti AT phys DOT uu DOT nl>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
cc: Elliott Oti <E DOT U DOT Oti AT phys DOT uu DOT nl>, djgpp AT delorie DOT com
Subject: Re: XWinAllegro
In-Reply-To: <Pine.SUN.3.91.980908175635.28479B-100000@is>
Message-ID: <Pine.OSF.3.95.980908213833.8685A-100000@ruunat.phys.uu.nl>
MIME-Version: 1.0

On Tue, 8 Sep 1998, Eli Zaretskii wrote:

> 
> On Tue, 8 Sep 1998, Elliott Oti wrote:
> 
> > allegro.h: In function `movedatal':
> > allegro.h:234: warning: cast to pointer from integer of different size
> > 
> > -- I let these ride.
> 
> Beware: Alpha's long is 64-bit wide whereas a pointer is 32 bits (or is it
> the other way around?), so the compiler tells you here that you are
> casting 64 bits to 32 bits, which is not a very good idea...
> 
> Many programs which assume that pointers and longs are the same size 
> break on Alpha (the core dump at run time).
> 

The program

int main()
{ printf("\n%d %d %d", sizeof(int), sizeof(long), sizeof(void *));
}

has as output

4 8 8

Thus ints are 32-bit, longs and pointers are 64-bit. So casting the ints
to pointers was OK, but saving the contents of a pointer in an int and
reusing it later will cause a core dump. Hmmm. Didn't know that.

Cheers,

  Elliott Oti
  http://www.fys.ruu.nl/~oti
  "Q: What did the elephant say to the naked man?
   A: It's cute but can you pick up peanuts with it?"


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019