weight(int x)
{

    if (x < COLS)
	return (double)x;
    else
	return COLS * (log((double)x / COLS) + 1.);
}

The product contains an iteration or loop with an exit condition that cannot be reached, i.e., an infinite loop.