Workaround internal gcc compiler error

It needs to be tested against the latest gcc trunk and a gcc bug
report raised if the problem still exists.
This commit is contained in:
Roland Winklmeier
2015-03-21 12:15:38 +01:00
parent 59007187fe
commit f1199793a7

View File

@@ -30,7 +30,23 @@ namespace BlackMisc
CAircraftEngine CAircraftEngineList::getEngine(int engineNumber) const
{
Q_ASSERT(engineNumber >= 0);
return this->findBy(&CAircraftEngine::getNumber, engineNumber).frontOrDefault();
// The following commented line results in a gcc compiler segfault:
//
// internal compiler error: in size_binop_loc, at fold-const.c:1450
// } // namespace
// ^
//
// frontOrDefault() is defined as:
// static const value_type def; return empty() ? def : front();
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Workaround it by using non static const value instead.
//return this->findBy(&CAircraftEngine::getNumber, engineNumber).frontOrDefault();
const CAircraftEngine def;
auto results = this->findBy(&CAircraftEngine::getNumber, engineNumber);
return results.empty() ? def : front();
}
bool CAircraftEngineList::isEngineOn(int engineNumber) const