]> git.ipfire.org Git - thirdparty/gcc.git/commit
c-family: avoid compile-time-hog in c_genericize [PR108880]
authorMarek Polacek <polacek@redhat.com>
Wed, 22 Feb 2023 20:17:03 +0000 (15:17 -0500)
committerMarek Polacek <polacek@redhat.com>
Wed, 22 Feb 2023 22:26:29 +0000 (17:26 -0500)
commit1370014f2ea02ec185cf1199027575916f79fe63
treea0f682e9c3913f1dd46f5976721757e55f088891
parent31303c9b5bab200754cdb7ef8cd91ae4918f3018
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.
gcc/c-family/c-gimplify.cc
gcc/testsuite/c-c++-common/ubsan/pr108880.c [new file with mode: 0644]