c++.beta - Bug: 'variable used before set' error
- Amnon Loeza (19/19) Dec 02 2003 typedef struct AB {
typedef struct AB {
int a;
int b;
} AB;
void func(AB *pAB, int count)
{ AB temp;
for (count--; count>=0; count--) {
temp = pAB[ count ];
temp.a /= 2; /* (A) */
temp.b /= 2; /* (B) */
pAB[ count ] = temp;
}
}
---
The code listed above gives a "Warning 12: variable 'struct AB temp' used before
set" when compiled with the -o+speed switch.
The compiler does not generate correct code for line (A); temp.a contains
unknown data. No problems with line (B).
It seems that only the first member of a structure is 'ignored'.
Dec 02 2003








Amnon Loeza <Amnon_member pathlink.com>