added "static_cast<int>"s and solved bug #377