#23 Structure Array - Address calculation bug.

closed-fixed
nobody
5
2000-09-30
2000-09-22
Anonymous
No

Sandeep et al.

I've still got an early version of 2.2.1 and I'm working with the LARGE MEMORY model, and I'm having problems with the following.

x = &fred[y];

where "fred" is a pointer to structure BUFF, and y is biggish.
I've looked at the asembler and what's happening is that a MUL is being done for y * "size of the structure". The problem is that only one byte of the result of the MUL, (the A) is being added to the pointer fred. The other half, B is not. So for small structures and small values of y, all is OK as B is zero, but for anything biggish, it's not!

I've changed my code to x = (BUFF *)(fred + y*sizeof(BUFF)) and all is OK.

Trefor Edwards

PS has the "duplicate function prototype problem" been fixed ??

i.e.
static void fred(int a);
static void fred(int a);

generates a error mesage... Is this valid C??

Discussion

  • Nobody/Anonymous

    Just seen 109715 - probably the same - that should teach me...

    Trefor

     
  • Sandeep Dutta

    Sandeep Dutta - 2000-09-30
    • status: open --> closed-fixed
     
  • Sandeep Dutta

    Sandeep Dutta - 2000-09-30

    Fixed in the latest source tree.

     

Log in to post a comment.