From 4b658e394b84042fa84ef4b68484e78bf5b6ea49 Mon Sep 17 00:00:00 2001 From: Nick Owens Date: Tue, 14 May 2024 16:05:30 -0700 Subject: [PATCH] fix assert in diary info panel clamp (#73758) 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. --- src/diary_ui.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/diary_ui.cpp b/src/diary_ui.cpp index ec26a4cbdb883..5542464753226 100644 --- a/src/diary_ui.cpp +++ b/src/diary_ui.cpp @@ -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 );