https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118306
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Simon Martin <simar...@gcc.gnu.org>: https://gcc.gnu.org/g:c74e7f651a014d59631361bcc9be05d797928c5c commit r15-7475-gc74e7f651a014d59631361bcc9be05d797928c5c Author: Simon Martin <si...@nasilyan.com> Date: Tue Feb 11 15:59:02 2025 +0100 c++: Reject cdtors and conversion operators with a single * as return type [PR118304, PR118306] We currently accept the following constructor declaration (clang, EDG and MSVC do as well), and ICE on the destructor declaration === cut here === struct A { *A (); ~A () = default; }; === cut here === The problem is that we end up in grokdeclarator with a cp_declarator of kind cdk_pointer but no type, and we happily go through (if we have a reference instead we eventually error out trying to form a reference to void). This patch makes sure that grokdeclarator errors out and strips the invalid declarator when processing a cdtor (or a conversion operator with no return type specified) with a declarator representing a pointer or a reference type. PR c++/118306 PR c++/118304 gcc/cp/ChangeLog: * decl.cc (maybe_strip_indirect_ref): New. (check_special_function_return_type): Take declarator as input. Call maybe_strip_indirect_ref and error out if it returns true. (grokdeclarator): Update call to check_special_function_return_type. gcc/testsuite/ChangeLog: * g++.old-deja/g++.jason/operator.C: Adjust bogus test expectation (char** vs char*). * g++.dg/parse/constructor4.C: New test. * g++.dg/parse/constructor5.C: New test. * g++.dg/parse/conv_op2.C: New test. * g++.dg/parse/default_to_int.C: New test.