https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108880
--- Comment #17 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:6ab4c8759754f34f5285924652238c829960cd4c commit r12-9218-g6ab4c8759754f34f5285924652238c829960cd4c Author: Marek Polacek <pola...@redhat.com> Date: Wed Feb 22 15:17:03 2023 -0500 c-family: avoid compile-time-hog in c_genericize [PR108880] This fixes a compile-time hog with UBSan. This only happened in cc1 but not cc1plus. The problem is ultimately that c_genericize_control_stmt/ STATEMENT_LIST -> walk_tree_1 doesn't use a hash_set to remember visited nodes, so it kept on recursing for a long time. We should be able to use the pset that c_genericize created. We just need to use walk_tree instead of walk_tree_w_d so that the pset is explicit. PR c/108880 gcc/c-family/ChangeLog: * c-gimplify.cc (c_genericize_control_stmt) <case STATEMENT_LIST>: Pass pset to walk_tree_1. (c_genericize): Call walk_tree with an explicit pset. gcc/testsuite/ChangeLog: * c-c++-common/ubsan/pr108880.c: New test. (cherry picked from commit 1370014f2ea02ec185cf1199027575916f79fe63)