From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 073E63858025; Sat, 4 Mar 2023 17:52:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 073E63858025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677952366; bh=Ct+52j3n+KClSc1F5drBnNBAGSA+CgJQSWicxOhHpVQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vaSCawe4z69Pe781XphrxeiongZJyOwexYCDR4RIwDX0Oy9qtQl3l2jGsRZchMrcM HBYaQn+nSFE/QJDFDm9IIWAKti8TxSpUiuuenIla2Qz2yLZ4wsXvDlzCWU29xX3tWg DUduGKpHaXsxhWTGJP3/vmzMTSe9JQEEXocfD5i4= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/106259] [10/11/12 Regression] ICE in diag_mismatched_tags, at cp/parser.cc:33896 Date: Sat, 04 Mar 2023 17:52:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106259 --- Comment #8 from CVS Commits --- The releases/gcc-12 branch has been updated by Marek Polacek : https://gcc.gnu.org/g:3a2310d4b229e707bbc5440150bf180e0499273a commit r12-9217-g3a2310d4b229e707bbc5440150bf180e0499273a Author: Marek Polacek Date: Wed Mar 1 14:28:46 2023 -0500 c++: ICE with -Wmismatched-tags and member template [PR106259] -Wmismatched-tags warns about the (harmless) struct/class mismatch. For, e.g., template struct A { }; class A a; it works by adding A to the class2loc hash table while parsing the class-head and then, while parsing the elaborate type-specifier, we add A. At the end of c_parse_file we go through the table and warn about the class-key mismatches. In this PR we crash though; we have template struct A { template struct W { }; }; struct A::W w; // #1 where while parsing A and #1 we've stashed A A::W A::W into class2loc. Then in class_decl_loc_t::diag_mismatched_tags TYPE is A::W, and specialization_of gets us A::W, which is not in class2loc, so we crash on gcc_assert (cdlguide). But it's OK not to have found A::W, we should just look one "level" up, that is, A::W. It's important to handle class specializations, so e.g. template<> struct A { template class W { }; }; where W's class-key is different than in the primary template above, so we should warn depending on whether we're looking into A or into a different instantiation. PR c++/106259 gcc/cp/ChangeLog: * parser.cc (class_decl_loc_t::diag_mismatched_tags): If the fi= rst lookup of SPEC didn't find anything, try to look for most_general_template. gcc/testsuite/ChangeLog: * g++.dg/warn/Wmismatched-tags-11.C: New test. (cherry picked from commit 71afd0628419c5d670701cb35bc9860380c7d9fb)=