Skip to content

Commit

Permalink
Fix issue with implicit conversion (value_proxy to rational) uncovere…
Browse files Browse the repository at this point in the history
…d by GCC 8
  • Loading branch information
mlang committed Jun 28, 2019
1 parent 8ba85fd commit 03546f2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class value_proxy

value_proxy(ast::simile &simile, rational const& simile_duration)
: type{ptr_type::simile}, simile_ptr{&simile}
, duration{simile_duration * simile.count}
, duration{simile_duration * int(simile.count)}
{ BOOST_ASSERT(simile_ptr->duration == zero); }

void make_beam_begin()
Expand Down Expand Up @@ -174,7 +174,10 @@ duration(std::vector<value_proxy> const &values)
return values.empty()
? zero
: std::accumulate(std::next(std::begin(values)), std::end(values),
static_cast<rational>(values.front()));
static_cast<rational>(values.front()),
[](rational const &a, value_proxy const &b) {
return a + rational(b);
});
}

struct global_state
Expand Down
2 changes: 1 addition & 1 deletion lib/lilypond.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ generator::operator() (braille::ast::moving_note const &chord)
(*this)(chord.base);
os << "}\\\\{";
// @todo Account for dotted intervals.
rational const moving_type(chord.base.as_rational() / chord.intervals.size());
rational const moving_type(chord.base.as_rational() / int(chord.intervals.size()));
for (braille::ast::interval const& interval: chord.intervals) {
os << " ";
ly_pitch_step(interval.step);
Expand Down
4 changes: 2 additions & 2 deletions lib/musicxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,11 +437,11 @@ class make_measures_for_staff_visitor : public boost::static_visitor<void> {
for (auto &&interval: moving_note.intervals) {
::musicxml::note xml_note {
pitch(interval),
duration(moving_note.base.as_rational() / moving_note.intervals.size(),
duration(moving_note.base.as_rational() / int(moving_note.intervals.size()),
divisions)
};

xml_note.type(note_type(moving_note.base.get_type() / moving_note.intervals.size()));
xml_note.type(note_type(moving_note.base.get_type() / int(moving_note.intervals.size())));
xml_note.dot(dots(moving_note.base));
if (interval.acc) xml_note.accidental(accidental(*interval.acc));
xml_note.staff(staff_number);
Expand Down
22 changes: 12 additions & 10 deletions lib/value_disambiguation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ class notegroup: public boost::static_visitor<void>
{
BOOST_ASSERT(stack_begin != stack_end);
return std::accumulate(std::next(stack_begin), stack_end,
static_cast<rational>(*stack_begin));
static_cast<rational>(*stack_begin),
[](rational const &a, value_proxy const &b) {
return a + rational(b);
});
}

tuplet_info const &tuplet_state() const { return tuplet; }
Expand Down Expand Up @@ -505,7 +508,7 @@ class partial_voice_interpreter
state.time_signature != 1 && maybe_whole_measure_rest(*iterator)) {
*stack_end = value_proxy(boost::get<ast::rest>(*iterator), state.time_signature);
recurse( std::next(iterator), end, stack_begin, std::next(stack_end)
, zero, position + state.time_signature, tuplet);
, zero, position + rational(state.time_signature), tuplet);
}
}
}
Expand Down Expand Up @@ -589,7 +592,7 @@ class large_and_small_visitor : public boost::static_visitor<bool>
if (!is_grace(value)) {
value_proxy *const next = proxy + 1;
if (fast_leq(*new(proxy)value_proxy(value, large_value, factor), max_duration)) {
rational const next_position(position + *proxy);
rational const next_position(position + rational(*proxy));
// If this is a tuplet end, only accept it if its position makes sense.
if (!dyadic_next_position || is_dyadic(next_position)) {
if (std::distance(rest, end) >= 10 && state.threads < max_threads) {
Expand All @@ -604,25 +607,25 @@ class large_and_small_visitor : public boost::static_visitor<bool>
new_proxy->set_tuplet_info(tuplet_begin, tuplet_end);
future = std::async(std::launch::async, [&]() {
interpreter.recurse( rest, end, new_stack.get(), new_proxy + 1
, max_duration - *new_proxy, next_position
, max_duration - rational(*new_proxy), next_position
, tuplet
);
state.threads--;
});
} else {
proxy->set_tuplet_info(tuplet_begin, tuplet_end);
interpreter.recurse( rest, end, stack_begin, next
, max_duration - *proxy, next_position, tuplet
, max_duration - rational(*proxy), next_position, tuplet
);
}
}
}
if (fast_leq(*new(proxy)value_proxy(value, small_value, factor), max_duration)) {
rational const next_position(position + *proxy);
rational const next_position(position + rational(*proxy));
if (!dyadic_next_position || is_dyadic(next_position)) {
proxy->set_tuplet_info(tuplet_begin, tuplet_end);
interpreter.recurse( rest, end, stack_begin, next
, max_duration - *proxy, next_position, tuplet
, max_duration - rational(*proxy), next_position, tuplet
);
}
}
Expand All @@ -635,8 +638,7 @@ class large_and_small_visitor : public boost::static_visitor<bool>
{
if (!position) { // full measure simile
BOOST_ASSERT(static_cast<bool>(interpreter.last_measure_duration()));
if (*new(proxy)value_proxy
(simile, interpreter.last_measure_duration()) > rational(0) &&
if (rational(*new(proxy)value_proxy(simile, interpreter.last_measure_duration())) > rational(0) &&
fast_leq(static_cast<rational>(*proxy) / rational::int_type(simile.count), max_duration)) {
rational const duration(static_cast<rational>(*proxy) / rational::int_type(simile.count));
interpreter.recurse( rest, end, stack_begin, proxy + 1
Expand Down Expand Up @@ -666,7 +668,7 @@ class large_and_small_visitor : public boost::static_visitor<bool>
tuplet.back().ttl = count_rhythmic(rest, tuplet_end(rest, end, tuplet.back().number, true));
}
interpreter.recurse( rest, end, stack_begin, proxy + 1
, max_duration - *proxy, position + *proxy
, max_duration - rational(*proxy), position + rational(*proxy)
, tuplet
);
}
Expand Down

0 comments on commit 03546f2

Please sign in to comment.