From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,c9e8a262ca84d551 X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1993-12-17 22:48:09 PST Path: gmd.de!xlink.net!sol.ctr.columbia.edu!news.kei.com!newsstand.cit.cornell.edu!lns598.lns.cornell.edu!dsr From: dsr@lns598.tn.cornell.edu (Daniel S. Riley) Newsgroups: comp.unix.osf.osf1 Subject: Re: OSF/ALPHA C compiler bug (not!) Followup-To: comp.unix.osf.osf1 Date: 17 Dec 1993 21:46:08 GMT Organization: Wilson Lab, Cornell U., Ithaca, NY 14853 Distribution: world Message-ID: References: <2et0mf$1v3@overload.lbl.gov> NNTP-Posting-Host: lns596.lns.cornell.edu 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