https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111329
--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:6f7f728746818062c3d6ed7ea9c7cb1562f2acb1 commit r14-3836-g6f7f728746818062c3d6ed7ea9c7cb1562f2acb1 Author: Jakub Jelinek <ja...@redhat.com> Date: Mon Sep 11 11:08:41 2023 +0200 pretty-print: Fix up pp_wide_int [PR111329] The recent pp_wide_int changes for _BitInt support (because not all wide_ints fit into the small fixed size digit_buffer anymore) apparently broke +FAIL: gcc.dg/analyzer/out-of-bounds-diagram-1-debug.c (test for excess errors) +FAIL: gcc.dg/analyzer/out-of-bounds-diagram-1-debug.c 2 blank line(s) in output +FAIL: gcc.dg/analyzer/out-of-bounds-diagram-1-debug.c expected multiline pattern lines 17-39 (and I couldn't reproduce that in bisect seed (which is -O0 compiled) and thought it would be some analyzer diagnostic bug). The problem is that analyzer uses pp_wide_int with a function call in the second argument. Previously, when pp_wide_int macro just did print_dec (W, pp_buffer (PP)->digit_buffer, SGN); pp_string (PP, pp_buffer (PP)->digit_buffer); it worked, because the const wide_int_ref & first argument to print_dec bound to a temporary, which was only destructed at the end of the full statement after print_dec was called. But with my changes where I need to first compare the precision of the const wide_int_ref & to decide whether to use digit_buffer or XALLOCAVEC something larger, this means that pp_wide_int_ref binds to a temporary which is destroyed at the end of full statement which is the const wide_int_ref &pp_wide_int_ref = (W); declaration, so then invokes UB accessing a destructed temporary. The following patch fixes it by rewriting pp_wide_int into an inline function, so that the end of the full statement is the end of the inline function call. As functions using alloca aren't normally inlined, I've also split that part into a separate out of line function. Putting that into pretty-print.cc didn't work, e.g. the gm2 binary doesn't link, because pretty-print.o is in libcommon.a, but wide-print-print.o which defines print_dec is not. So I've put that out of line function into wide-int-print.cc instead. 2023-09-11 Jakub Jelinek <ja...@redhat.com> PR middle-end/111329 * pretty-print.h (pp_wide_int): Rewrite from macro into inline function. For printing values which don't fit into digit_buffer use out-of-line function. * wide-int-print.h (pp_wide_int_large): Declare. * wide-int-print.cc: Include pretty-print.h. (pp_wide_int_large): Define.