While compiling the current pymol svn with gcc trunk
I ran across a compilation warning...
Ortho.c: In function 'OrthoFree':
Ortho.c:1973: warning: array subscript is above array bounds
which doesn't seem to make sense. The reduced test case that
triggers it with -O3 -Wall is...
#define CMD_QUEUE_MASK 0x3
void OrthoFree()
{
typedef struct {
char *ptr;
unsigned int inp,out;
unsigned int mask,size;
} CQueue;
struct _COrtho {
int X,Y,Height,Width;
CQueue *cmdQueue[CMD_QUEUE_MASK+1];
};
typedef struct _COrtho COrtho;
register COrtho *I=((void *)0);
int a;
for(a=0;a<=CMD_QUEUE_MASK;a++)
;
I->cmdQueue[a] = ((void *)0);
}
which produces the warning...
test.c: In function ‘OrthoFree’:
test.c:24: warning: array subscript is above array bounds
...for the last assignment of I->cmdQueue[a] = ((void *)0).
It would seem to me that 'a' should be CMD_QUEUE_MASK+1
on exiting the for statement so that the assignment should
be valid. Thanks in advance for any feedback as to whether
I should open a PR for this against gcc trunk.
Jack