www.digitalmars.com         C & C++   DMDScript  

c++.beta - Bug: 'variable used before set' error

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