https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113389
--- Comment #2 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:9840e0be78150b0ef6e29975a6244698d5a5580c commit r14-8239-g9840e0be78150b0ef6e29975a6244698d5a5580c Author: Marek Polacek <pola...@redhat.com> Date: Wed Jan 17 19:16:32 2024 -0500 c++: ICE when xobj is not the first parm [PR113389] In grokdeclarator/cdk_function the comment says that the find_xobj_parm lambda clears TREE_PURPOSE so that we can correctly detect an xobj that is not the first parameter. That's all good, but we should also clear the TREE_PURPOSE once we've given the error, otherwise we crash later in check_default_argument because the 'this' TREE_PURPOSE lacks a type. PR c++/113389 gcc/cp/ChangeLog: * decl.cc (grokdeclarator) <case cdk_function>: Set TREE_PURPOSE to NULL_TREE when emitting an error. gcc/testsuite/ChangeLog: * g++.dg/cpp23/explicit-obj-diagnostics10.C: New test.