From 03546f22b69000921dd1589bd99f5ee7b54f33e8 Mon Sep 17 00:00:00 2001 From: Mario Lang Date: Fri, 28 Jun 2019 08:46:00 +0200 Subject: [PATCH] Fix issue with implicit conversion (value_proxy to rational) uncovered by GCC 8 --- .../value_disambiguation.hpp | 7 ++++-- lib/lilypond.cpp | 2 +- lib/musicxml.cpp | 4 ++-- lib/value_disambiguation.cpp | 22 ++++++++++--------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/bmc/braille/semantic_analysis/value_disambiguation.hpp b/include/bmc/braille/semantic_analysis/value_disambiguation.hpp index 30a772c..6807c95 100644 --- a/include/bmc/braille/semantic_analysis/value_disambiguation.hpp +++ b/include/bmc/braille/semantic_analysis/value_disambiguation.hpp @@ -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() @@ -174,7 +174,10 @@ duration(std::vector const &values) return values.empty() ? zero : std::accumulate(std::next(std::begin(values)), std::end(values), - static_cast(values.front())); + static_cast(values.front()), + [](rational const &a, value_proxy const &b) { + return a + rational(b); + }); } struct global_state diff --git a/lib/lilypond.cpp b/lib/lilypond.cpp index 86e5f21..4f287aa 100644 --- a/lib/lilypond.cpp +++ b/lib/lilypond.cpp @@ -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); diff --git a/lib/musicxml.cpp b/lib/musicxml.cpp index 83eb22e..4f95792 100644 --- a/lib/musicxml.cpp +++ b/lib/musicxml.cpp @@ -437,11 +437,11 @@ class make_measures_for_staff_visitor : public boost::static_visitor { 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); diff --git a/lib/value_disambiguation.cpp b/lib/value_disambiguation.cpp index fd060e8..9cb82c7 100644 --- a/lib/value_disambiguation.cpp +++ b/lib/value_disambiguation.cpp @@ -266,7 +266,10 @@ class notegroup: public boost::static_visitor { BOOST_ASSERT(stack_begin != stack_end); return std::accumulate(std::next(stack_begin), stack_end, - static_cast(*stack_begin)); + static_cast(*stack_begin), + [](rational const &a, value_proxy const &b) { + return a + rational(b); + }); } tuplet_info const &tuplet_state() const { return tuplet; } @@ -505,7 +508,7 @@ class partial_voice_interpreter state.time_signature != 1 && maybe_whole_measure_rest(*iterator)) { *stack_end = value_proxy(boost::get(*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); } } } @@ -589,7 +592,7 @@ class large_and_small_visitor : public boost::static_visitor 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) { @@ -604,7 +607,7 @@ class large_and_small_visitor : public boost::static_visitor 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--; @@ -612,17 +615,17 @@ class large_and_small_visitor : public boost::static_visitor } 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 ); } } @@ -635,8 +638,7 @@ class large_and_small_visitor : public boost::static_visitor { if (!position) { // full measure simile BOOST_ASSERT(static_cast(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(*proxy) / rational::int_type(simile.count), max_duration)) { rational const duration(static_cast(*proxy) / rational::int_type(simile.count)); interpreter.recurse( rest, end, stack_begin, proxy + 1 @@ -666,7 +668,7 @@ class large_and_small_visitor : public boost::static_visitor 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 ); }