https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86567
--- Comment #4 from Alexander Monakov <amonakov at gcc dot gnu.org> --- I think the problem is not exactly that maybe_constant_value keeps a lookup cache, but rather that invoking maybe_constant_value may cause allocation of uids. So it wouldn't be enough to simply avoid populating the cache in warning context. It seems a bit strange to do full-blown constexpr evaluation for warnings, especially if normal compilation flow wouldn't perform the same evaluation. Wouldn't it make sense to use some more light-weight lookup for warning purposes? On this testcase we allocate a new uid via allocate_decl_uid () make_node (code=RESULT_DECL) build_decl (loc=13709891, code=RESULT_DECL, name=0x0, type=0x7ffff0d86e70) start_preparsed_function(tree_node*, tree_node*, int) () instantiate_decl(tree_node*, bool, bool) () instantiate_cx_fn_r (tp=0x7ffff0d88c98, walk_subtrees=0x7fffffffd528) walk_tree_1 walk_tree_1 walk_tree_1 walk_tree_without_duplicates_1 instantiate_constexpr_fns (t=0x7ffff0d88ea0) cxx_eval_outermost_constant_expr maybe_constant_value (t=0x7ffff0d88ea0, decl=0x0) build_over_call (cand=0x27a65a0, flags=1, complain=3) build_new_method_call_1 build_new_method_call build_special_member_call expand_aggr_init_1(tree_node*, tree_node*, tree_node*, tree_node*, int, int) () emit_mem_initializers(tree_node*) () tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) () tsubst_expr(tree_node*, tree_node*, int, tree_node*, bool) () instantiate_decl(tree_node*, bool, bool) () instantiate_pending_templates(int) () c_parse_final_cleanups() () compile_file() () toplev::main(int, char**) () main ()