Skip to content

Commit

Permalink
Fix a possible UB in kislager::do_static_cast
Browse files Browse the repository at this point in the history
The getter argument should be const-ref for now

See this bug-report:
arximboldi/lager#160
  • Loading branch information
dimula73 committed Aug 1, 2024
1 parent 1f3ff8f commit f4e2b00
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/global/KisLager.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ constexpr auto scale_real_to_int = [] (qreal multiplier) {
);
};

template <typename Src, typename Dst>
template <typename Src, typename Dst, typename SrcConstRef = std::add_lvalue_reference_t<std::add_const_t<Src>>>
auto do_static_cast = lager::lenses::getset(
[] (Src value) { return static_cast<Dst>(value); },
[] (SrcConstRef value) { return static_cast<Dst>(value); },
[] (Src, Dst value) { return static_cast<Src>(value); }
);

Expand Down

0 comments on commit f4e2b00

Please sign in to comment.