To compile my C++ code I use the -W
flag, which causes the warning:
warning: comparison of unsigned expression < 0 is always false
I believe this was considered as a bug and was fixed on version GCC 4.3, but I'm using GCC 4.1
Code that is obviously offending here:
void FieldGroup::generateCreateMessage (const ApiEvent::GroupData &data, omsgstream &result) const {
dblog << debug;
// Write out the data fields we care about, in the order they were specified
for (size_t index = 0; index < fields.size(); ++index) {
size_t esIndex = clsToES[index];
if (esIndex < 0 || esIndex >= data.fields.length()) {
ostringstream buf;
buf << "Invalid field " << index << " (index in ES data set " << esIndex << ", " << data.fields.length() << " fields returned)";
throw InvalidDataException (buf.str());
}
fields[index].writeData (data.fields[esIndex], result);
}
}
Warning I'm getting:
dbtempl.cpp: In member function ‘void ECONZ::FieldGroup::generateCreateMessage(const nz::co::econz::eventServer::ApiEvent::GroupData&, ECONZ::omsgstream&) const’: dbtempl.cpp:480: warning: comparison of unsigned expression < 0 is always false
How can i possibly stop these warnings from appearing? I don't want to remove the -W
flag.