Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: amziod@world.std.com (Merritt)
Subject: casting bug/feature?
Date: Sat, 18 Dec 1993 03:35:25 GMT	[thread overview]
Message-ID: <CI7on2.3zy@world.std.com> (raw)

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


                 reply	other threads:[~1993-12-18  3:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
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