I have the following code:
void CScriptTable::EnumReferences(asIScriptEngine *engine)
{
if (m_table)
{
// Call the gc enum callback for each nested table
size_t col = 0, row = 0, num_cols = m_table->numCols(),
num_rows = m_table->numRows();
for(col; col < num_cols; col++) // Line 92
{
if (m_table->getColType(col) == COL_TABLE)
{
for (row; row < num_rows; row++) // Line 95
{
Table * tbl = m_table->getTable(row, col);
engine->GCEnumCallback(tbl);
}
}
}
}
}
When compiling, (g++), the warning ("statement has no effect") is issued for line 92 & 95 (indicated in the snippet above).
I can't see why they don't have any effect, even though I have been staring at it for a while. What am I missing?
rowis set at 0 once, before entering thecolloop, and never reset afterwards. Therefore, on the first iteration of the outer (col) loop, you do iterate on the rows, but for all the other iterations, you just do nothing. See @b.buchhold's answer which solve both your original question and this bug... and learn to declare your variables in as tight a scope as possible.