Skip to content

build: remove constexpr for gcc9

Andreas Rauschert requested to merge fix_constexpr into main

When compiling with gcc9 it will throw an error because the unary operator- in units is not recognized as constexpr:

external/open_scenario_engine/src/Storyboard/ByEntityCondition/TimeHeadwayCondition_impl.cpp: In function 'constexpr units::angle::radian_t OpenScenarioEngine::v1_3::detail::NormalizeAngle(units::angle::radian_t)':
external/open_scenario_engine/src/Storyboard/ByEntityCondition/TimeHeadwayCondition_impl.cpp:31:19: error: call to non-'constexpr' function 'units::unit_t<Units, T, NonLinearScale> units::operator-(const units::unit_t<Units, T, NonLinearScale>&) [with Units = units::unit<std::ratio<1>, units::base_unit<std::ratio<0, 1>, std::ratio<0, 1>, std::ratio<0, 1>, std::ratio<1> > >; T = double; NonLinearScale = units::linear_scale]'
   31 |   while (angle < -pi)
      |                   ^~

I think it is a false positive of the compiler because to me it seems that the unary operator- is defined as constexpr:

	// unary addition: -T
	template<class Units, typename T, template<typename> class NonLinearScale>
	inline constexpr unit_t<Units, T, NonLinearScale> operator-(const unit_t<Units, T, NonLinearScale>& u) noexcept
	{
		return unit_t<Units, T, NonLinearScale>(-u());
	}

Anyway this is the quick fix because integration of osc1engine is currently blocked.

Edited by Andreas Rauschert

Merge request reports

Loading