www.digitalmars.com         C & C++   DMDScript  

c++.beta - Bug: 'Warning 12: 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 compiler gives a "Warning 12: variable 'struct AB temp' used before set"
warning for the code listed above.

No data for member a is copied into variable 'temp'; temp.a (line (A)) contains
unknown data. This is not the case for line (B).

It seems that only the first member of a structure isn't copied.
Dec 02 2003