Question of Ignorance

Morris M. Keesan keesan at bbnccv.UUCP
Thu May 16 00:45:31 AEST 1985


--------------------------------------------------------------------
> > ... I recommend using one of the two constructs
> > 
> >     ( longptr == (long *)32 )
> > or  ( (int)longptr == 32 )
> > 
> > which are guaranteed to do what you want ...
> 
> Argh, WRONG!!  Turn that "(int)" into "(long)" and I might agree.  You
> have no guarantees that an int is long enough to hold a pointer.

Nor do you have any guarantees that a long is enough to hold a pointer.  I
was thinking that the (int) cast was sufficient because 32 is an int, but on
reflection I see that it might truncate longptr and give a result of TRUE if
the low-order int of longptr were 32.  I hereby retract my recommendation of
the second form, but stand by the first, which was my preference anyway.
---------------------------------
Morris M. Keesan
{decvax,ihnp4,etc.}!bbncca!keesan
keesan at bbn-unix.ARPA



More information about the Comp.lang.c mailing list