c/1570: gcc 2.8.1 has autoincrement bug
rglan@engr.sgi.com
rglan@engr.sgi.com
Fri Jan 5 17:16:00 GMT 2001
>Number: 1570
>Category: c
>Synopsis: gcc 2.8.1 has autoincrement bug
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Fri Jan 05 17:16:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Rob Glanville
>Release: gcc 2.8.1
>Organization:
>Environment:
Irix64 release 6.5
>Description:
When useing an index into an array, and autoincrementing the index,
the compiler doesn't generate the code to autoincrement the index.
=============Code sample======================
#include <stdio.h>
unsigned long Point;
unsigned char buf[8];
unsigned char val;
int main(void) {
Point = 0;
buf[0] = 1;
buf[1] = 0;
buf[2] = 1;
val = (buf[Point++] << 2) | (buf[Point++] << 1) | (buf[Point++]);
printf("val = %x, Point = %x\n",val,Point);
return(0);
}
=============end of sample===================
produces an output of;
val=7, Point=1;
I understand that the expression isn't really legal since
it involves autoincrementing an index in a certain order
that isn't guarenteed by any compiler, but it should at
least increment the index pointer as it evaluates the
expression.
>How-To-Repeat:
Compile small source code. Run it. Output should be;
val=5, Point=3
where val is there bits ORed together and Point is the array index pointer
>Fix:
Make autoincrements work at all times.
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list