GCC-7: fix segfault in static init

seemingly this code was brittle: GCC-7 treats int64_t as long,
which leads to preferring the template specialisation over the
explicit version of the operator* -- which means the template
instantiation invokes itself.
This commit is contained in:
Fischlurch 2018-04-28 03:02:02 +02:00
parent f06038828c
commit f99637285a
3 changed files with 11 additions and 10 deletions

View file

@ -45,7 +45,7 @@ namespace engine {
const rational<uint> ONE_THIRD(1,3);
const rational<uint> EIGHTY_PERCENT(8,10);
const Duration DEFAULT_ENGINE_LATENCY = EIGHTY_PERCENT * Duration(1, FrameRate::PAL);
const Duration DEFAULT_ENGINE_LATENCY = EIGHTY_PERCENT * Duration(1, FrameRate{25}); ///////TODO: shouldn't be hard wired and shouldn't be calculated in static/global init
const Duration DEFAULT_JOB_PLANNING_TURNOVER(FSecs(3,2));
}//(End)hard wired settings

View file

@ -213,10 +213,11 @@ namespace time {
/** @internal stretch offset by a possibly fractional factor, and quantise into raw (micro tick) grid */
Offset
operator* (boost::rational<int64_t> factor, Offset const& o)
Offset::stretchedByRationalFactor (boost::rational<int64_t> factor) const
{
boost::rational<int64_t> distance (_raw(o));
boost::rational<int64_t> distance (this->t_);
distance *= factor;
gavl_time_t microTicks = floordiv (distance.numerator(), distance.denominator());
return Offset(TimeValue(microTicks));

View file

@ -293,7 +293,7 @@ namespace time {
TimeValue::operator= (o);
return *this;
}
public:
explicit
Offset (TimeValue const& distance =Time::ZERO)
@ -315,6 +315,10 @@ namespace time {
return TimeValue(std::llabs (t_));
}
/** @internal stretch offset by a possibly fractional factor,
* and quantise into raw (micro tick) grid */
Offset stretchedByRationalFactor (boost::rational<int64_t>) const;
/** @internal diagnostics, indicating ∆ */
operator std::string () const;
@ -350,15 +354,11 @@ namespace time {
template<typename INTX>
inline Offset
operator* (boost::rational<INTX> factor, Offset const& o)
operator* (boost::rational<INTX> factor, Offset const& offset)
{
return boost::rational<int64_t>(factor.numerator(), factor.denominator()) * o;
return offset.stretchedByRationalFactor (boost::rational<int64_t>(factor.numerator(), factor.denominator()));
}
/** stretch offset by a possibly fractional factor */
Offset
operator* (boost::rational<int64_t> factor, Offset const& o);
/** flip offset direction */
inline Offset