From: Jakub Jelinek Date: Thu, 22 Jan 2026 09:11:34 +0000 (+0100) Subject: unswitch: Fix up one unguarded fprintf (dump_file, ...) [PR123736] X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=613fef9239aa723ea65b1118262bb63d023169c4;p=thirdparty%2Fgcc.git unswitch: Fix up one unguarded fprintf (dump_file, ...) [PR123736] This dump message is not guarded on dump_file being non-NULL, so crashes inside of libc if dump_file is NULL. I think a message like that is usually guarded not just on dump_file being non-NULL, but also on TDF_DETAILS set in dump_flags. 2026-01-22 Jakub Jelinek PR tree-optimization/123736 * tree-ssa-loop-unswitch.cc (hoist_guard): Guard dump message on dump_file && (dump_flags & TDF_DETAILS) condition. --- diff --git a/gcc/tree-ssa-loop-unswitch.cc b/gcc/tree-ssa-loop-unswitch.cc index 7831a442851..96680bc64ea 100644 --- a/gcc/tree-ssa-loop-unswitch.cc +++ b/gcc/tree-ssa-loop-unswitch.cc @@ -1459,7 +1459,8 @@ hoist_guard (class loop *loop, edge guard) if (skip_count > e->count ()) { - fprintf (dump_file, " Capping count; expect profile inconsistency\n"); + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " Capping count; expect profile inconsistency\n"); skip_count = e->count (); } if (dump_enabled_p ())