https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>:

https://gcc.gnu.org/g:21968d4ae067e3fa1c1728c8db26478e8ac8ad0b

commit r11-175-g21968d4ae067e3fa1c1728c8db26478e8ac8ad0b
Author: Marek Polacek <pola...@redhat.com>
Date:   Fri Apr 17 23:48:11 2020 -0400

    c++: Fix crash with template spec in different namespace [PR94255]

    This is an ICE on invalid, because we're specializing S::foo in the
    wrong namespace.  cp_parser_class_specifier_1 parses S::foo in M
    and then it tries to push the nested-name-specifier of foo, which is
    S.  By that, we're breaking the assumption of push_inner_scope that
    the pushed scope must be a scope nested inside current scope: current
    scope is M, but the namespace context of S is N, and N is not nested
    in M, so we fell into an infinite loop in push_inner_scope_r.

    (cp_parser_class_head called check_specialization_namespace which already
    gave a permerror.)

            PR c++/94255
            * parser.c (cp_parser_class_specifier_1): Check that the scope is
            nested inside current scope before pushing it.

            * g++.dg/template/spec41.C: New test.

Reply via email to