Several gcc and clang fixes

This superseeds also f1199793 by a cleaner workaround.
This commit is contained in:
Roland Winklmeier
2015-03-24 02:06:16 +01:00
committed by Roland Winklmeier
parent 70e42c0bee
commit ab98009996
4 changed files with 4 additions and 20 deletions

View File

@@ -33,7 +33,7 @@ namespace BlackGui
BlackMisc::Aviation::CCallsign CRemoteAircraftSelector::getSelectedCallsign() const
{
const CCallsign empty;
const CCallsign empty {};
int index = ui->cb_RemoteAircraftSelector->currentIndex();
if (index < 0 || index > this->m_aircraft.size()) { return empty; }
return m_aircraft[index].getCallsign();

View File

@@ -24,7 +24,7 @@ namespace BlackMisc
public:
//! Default constructor
CAircraftEngine() = default;
CAircraftEngine() {}
//! Constructor
CAircraftEngine(int number, bool on);

View File

@@ -30,23 +30,7 @@ namespace BlackMisc
CAircraftEngine CAircraftEngineList::getEngine(int engineNumber) const
{
Q_ASSERT(engineNumber >= 0);
// 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();
return this->findBy(&CAircraftEngine::getNumber, engineNumber).frontOrDefault();
}
bool CAircraftEngineList::isEngineOn(int engineNumber) const

View File

@@ -165,7 +165,7 @@ namespace BlackMisc
/*!
* \brief Access the first element, or a default-initialized value if the sequence is empty.
*/
const_reference frontOrDefault() const { static const value_type def; return empty() ? def : front(); }
const_reference frontOrDefault() const { static const value_type def {}; return empty() ? def : front(); }
/*!
* \brief Access the first element, or a default-initialized value if the sequence is empty.