https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70342
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
1011 cp_fold_function (tree fndecl)
1012 {
1013 cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_fold_r, NULL, NULL);
1014 }
so we walk duplicates more than once. Changing it to use
cp_walk_tree_without_duplicate fixes this.
So it seems -fsanitize=undefined introduces some tree cycles in what
cp_walk_tree
walks (for example via sharing tree nodes).
