https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113340
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:ac219d524ace47eea5bf5404b267e22950f44030 commit r14-8165-gac219d524ace47eea5bf5404b267e22950f44030 Author: Marek Polacek <pola...@redhat.com> Date: Tue Jan 16 15:49:46 2024 -0500 c++: fix ICE with xobj in destructor [PR113340] Here we crash in maybe_retrofit_in_chrg on an invalid dtor with explicit this. Such member functions do not get converted to METHOD_TYPE. If a dtor gets parameters, we reset arg_types to void_list_node in grokdeclarator. This results in m_r_in_c receiving: void <T8d> (void) and crashing on parms = DECL_CHAIN (DECL_ARGUMENTS (fn)); This patch avoids the ICE by resetting is_xobj_member_function after emitting the error. Then m_r_in_c gets void S::<T40b> (struct S *) which does not cause a crash. PR c++/113340 gcc/cp/ChangeLog: * decl.cc (grokdeclarator) <case cdk_function>: Clear is_xobj_member_function in case of an error. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics9.C: New test.