https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116108
--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:11919b5ac5e5b3c00fda2e2f0b8ce4d53f78691d commit r12-11159-g11919b5ac5e5b3c00fda2e2f0b8ce4d53f78691d Author: Jakub Jelinek <ja...@redhat.com> Date: Tue Dec 17 10:13:24 2024 +0100 c++: Diagnose earlier non-static data members with cv containing class type [PR116108] In r10-6457 aka PR92593 fix a check has been added to reject earlier non-static data members with current_class_type in templates, as the deduction then can result in endless recursion in reshape_init. It fixed the template <class T> struct S { S s = 1; }; S t{2}; crashes, but as the following testcase shows, didn't catch when there are cv qualifiers on the non-static data member. Fixed by using TYPE_MAIN_VARIANT. 2024-12-17 Jakub Jelinek <ja...@redhat.com> PR c++/116108 gcc/cp/ * decl.cc (grokdeclarator): Pass TYYPE_MAIN_VARIANT (type) rather than type to same_type_p when checking if the non-static data member doesn't have current class type. gcc/testsuite/ * g++.dg/cpp1z/class-deduction117.C: New test. (cherry picked from commit 88bfee560681d8248b89f130ada249e35ee2e344)