Skip to content

Commit

Permalink
fix assert in diary info panel clamp (CleverRaven#73758)
Browse files Browse the repository at this point in the history
with -D_GLIBCXX_ASSERTIONS=1, libstdc++ will assert when `lo > hi` in
std::clamp, and it is described as undefined behavior in
https://en.cppreference.com/w/cpp/algorithm/clamp. fix the arguments to
avoid it.
  • Loading branch information
mischief authored May 14, 2024
1 parent e141d5c commit 4b658e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/diary_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ void diary::show_diary_ui( diary *c_diary )
const point &beg = beg_and_max.first;
const point &max = beg_and_max.second;

w_info = catacurses::newwin( std::clamp( 3, max.y / 2 - 4, 7 ), max.x + 9, beg + point( -4,
int lines = std::clamp( max.y / 2 - 4, 3, 7 );

w_info = catacurses::newwin( lines, max.x + 9, beg + point( -4,
3 + max.y + ( max.y > 12 ) ) );

ui.position_from_window( w_info );
Expand Down

0 comments on commit 4b658e3

Please sign in to comment.