[comp.sys.mac.programmer] Bug

woody@tybalt.caltech.edu (William Edward Woody) (05/01/88)

I think I've found a bug in MPW C v2.0.2.  Can others out there
verify if this is a problem?

The bug:
    In the expression:

       screen->h = (page->h) >> p2wscale + xOffset;

    where the variables above are:

    Point *screen,*page;
    short p2wscale,xOffset;

    If p2wscale == 0, the value of screen->h is set to xOffset; the
expression (page->h) >> p2wscale evaluates to 0, even when page->h is
not zero.

    Shouldn't screen->h evaluate to page->h + xOffset when p2wscale is
zero?

    Has others noticed this problem?  Please respond directly to me, as
I sometimes don't read this net too closely, and responces can sometimes
slip through.
  -  William Edward Woody
     woody@tybalt.caltech.edu                   (Mac>][n&&/|\)&&(MacII>AT)
Disclamer:  I haven't the foggiest idea what I'm talking about...

kaufman@polya.STANFORD.EDU (Marc T. Kaufman) (05/01/88)

In article <6330@cit-vax.Caltech.Edu> woody@tybalt.caltech.edu (William Edward Woody) writes:

>I think I've found a bug in MPW C v2.0.2.  Can others out there
>verify if this is a problem?

>The bug:
>    In the expression:

>       screen->h = (page->h) >> p2wscale + xOffset;

According to the C standard (and, indeed, according to the compiler), this
expression is evaluated as:

	screen->h = (page->h) >> (p2wscale + xOffset);

since '+' has a higher precedence than '>>'