From: dsr@lns598.tn.cornell.edu (Daniel S. Riley)
Subject: Re: OSF/ALPHA C compiler bug (not!)
Date: 17 Dec 1993 21:46:08 GMT [thread overview]
Message-ID: <DSR.93Dec17164608@lns596.lns.cornell.edu> (raw)
In-Reply-To: jin@gracie.lbl.gov's message of 17 Dec 1993 19:18:39 GMT
In article <2et0mf$1v3@overload.lbl.gov>,
jin@gracie.lbl.gov (Guojun Jin[ITG]) writes:
Guojun> float f=0.0;
Guojun> char *cp;
Guojun> int *ip=(int*)&cp;
Guojun> *ip = f;
Guojun> if (cp != NULL)
Guojun> printf("cp is not NULL, but -> %d\n", cp);
Guojun> printf("Cp is %u\n", cp);
Those should be
if (cp != NULL)
printf("cp is not NULL, but -> %ld\n", cp);
printf("Cp is %lu\n", cp);
remember, sizeof (char *) > sizeof (int). %d interprets the object
as an int, which only shows you half of cp. Similarly, *ip only sets
half of cp, as you'll discover when you get the printf() formats right.
In short, not a compiler bug.
--
-Dan Riley Internet: dsr@lns598.tn.cornell.edu
-Wilson Lab, Cornell University HEPNET/SPAN: lns598::dsr (44630::dsr)
"Distance means nothing/To me." -Kate Bush
next prev parent reply other threads:[~1993-12-17 21:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1993-12-17 19:18 OSF/ALPHA C compiler bug Guojun Jin[ITG]
1993-12-17 19:55 ` David J. MacKenzie
1993-12-17 21:46 ` Daniel S. Riley [this message]
1994-01-13 21:38 ` Dennis Murphy
1994-01-13 21:44 ` Dennis Murphy
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox