Borland Turbo C 2.0 for Atari 68000 machines: ODD behavior

Adam S. Denton asd at cbnewsj.att.com
Sat Apr 20 03:20:24 AEST 1991


In article <690004 at hplvec.LVLD.HP.COM> boyne at hplvec.LVLD.HP.COM (Art Boyne) writes:
>>In comp.lang.c, pardo at june.cs.washington.edu (David Keppel) writes:
>>
>>    carter at cs.wisc.edu (Gregory Carter) writes:
>>    > (unsigned int)(*((unsigned int *)0xffff8e20L)) = 0x03;
>>    >translates to:
>>    >                       MOVE.W #$0003, $8e20
>>    >This is obviously not correct.
>>
>>    I'll agree that it isn't what I *expected* but it is *correct*.
>>    Here are some other correct implementations:
>>
>>     * Compiler refuses to compile the program
>>     * Program aborts when executed
>>     * Program runs `rogue'
>>     * Program assigs 3 to memory location 0xffff8e20
>
>You don't seem to understand:  MOVE.W #$0003, $8e20, assuming that the

He understands.  This debate is apparently what assigning
to a casted expression should do.  The above is very clearly
    (cast) [something] = [some value];
which has never been defined to have any meaning whatsoever.
Let's not forget what GIGO stands for!

Now, consider rewriting that expression...instead of:
>>    > (unsigned int)(*((unsigned int *)0xffff8e20L)) = 0x03;
Why not toss the (unsigned int) cast?  What on earth is it there for anyway?
Maybe it should be before the 0x03 instead, or left out entirely.

If one removes the cast, *then* the statement has meaning, and ONLY then is
there a platform on which to decide whether the compiler's correct or not.
But as it stands, there's no reason why the statement *shouldn't* run `rogue'!

Adam Denton
asd at mtqua.att.com



More information about the Comp.lang.c mailing list