From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,c23fbc6c4736c056,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1993-12-18 03:49:01 PST Newsgroups: comp.unix.osf.osf1 Path: gmd.de!newsserver.jvnc.net!howland.reston.ans.net!cs.utexas.edu!uunet!world!amziod From: amziod@world.std.com (Merritt) Subject: casting bug/feature? Message-ID: Keywords: cast Organization: The World Public Access UNIX, Brookline, MA Date: Sat, 18 Dec 1993 03:35:25 GMT While porting a PC application to OSF-1 on the DEC Alpha, I ran into what I thought was an OSF-1 bug but which I was assured was my own bug. If you cast a byte pointer to a short, you get the correct value in the short except if the byte address happens to end in 7 or F, in which case you get the int built out of two different bytes in the word. This was a particulary hard bug (in my program?) to find since the casts work well on non-RISC platforms (DOS and Ultrix) and DBX under OSF-1 treats them correctly. DEC support, correctly, claims that C does not guarantee anything reasonable will happen when casting (down/up?) from a byte pointer. I found it unnerving, however, because that particular cast works well on most boundaries, including odd ones, just fails on two particular alignments. Also other casts, such as ints to shorts all seem to work as expected. Dennis -- Amziod 40 Samuel Prescott Dr. Stow, MA 01775 USA Tel 508/897-7332, FAX 508/897-2784