compiler bug?

Date view Thread view Subject view

From: MagerValp (MagerValp_at_cling.gu.se)
Date: 1999-07-09 19:09:09


I think something's broken in cc65 -- x[y>>n] doesn't seem to work the
way it should. Try the following:

#include <stdio.h>
#include <stdlib.h>

int main (void)
{
  unsigned char c[4];
  unsigned int y;

  c[0] = 0;
  c[1] = 1;
  c[2] = 2;
  c[3] = 3;

  printf("c[0]=%d, c[1]=%d, c[2]=%d, c[3]=%d\n", c[0], c[1], c[2], c[3]);

  for (y=0; y<8; y++) {
    printf("y=%d; c[y & 3]=%d\n", y, c[y & 3]);
  }

  for (y=0; y<8; y++) {
    printf("y=%d; y>>1=%d; c[(y>>1)]=%d\n", y, (y>>1), c[(y>>1)]);
  }
}

With gcc the last loop prints:

y=0; y>>1=0; c[(y>>1)]=0
y=1; y>>1=0; c[(y>>1)]=0
y=2; y>>1=1; c[(y>>1)]=1
y=3; y>>1=1; c[(y>>1)]=1
y=4; y>>1=2; c[(y>>1)]=2
y=5; y>>1=2; c[(y>>1)]=2
y=6; y>>1=3; c[(y>>1)]=3
y=7; y>>1=3; c[(y>>1)]=3

but with cc65 i get:

y=0; y>>1=0; c[(y>>1)]=0
y=1; y>>1=0; c[(y>>1)]=1
y=2; y>>1=1; c[(y>>1)]=1
y=3; y>>1=1; c[(y>>1)]=2
y=4; y>>1=2; c[(y>>1)]=2
y=5; y>>1=2; c[(y>>1)]=3
y=6; y>>1=3; c[(y>>1)]=3
y=7; y>>1=3; c[(y>>1)]=0

(see http://www.cling.gu.se/~cl3polof/bug.gif for the full cc65
output)

Am I missing something here or is cc65 broken?

% cc65 -V
cc65 V2.2.0
cc65: No input files

% gcc --version
2.8.0

% uname -a
SunOS frege.cling.gu.se 5.5.1 Generic sun4u sparc SUNW,Ultra-1. 

cc65 was built from source.

-- 
    ___          .     .  .         .       . +  .         .      o   
  _|___|_   +   .  +     .     +         .   .  Per Olofsson, konstnär
    o-o    .      .     .   o         +          MagerValp_at_cling.gu.se
     -       +            +    .     http://www.cling.gu.se/~cl3polof/
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:44 CET