[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 Marek Polacek changed: What|Removed |Added Resolution|--- |FIXED Status|ASSIGNED|RESOLVED --- Comment #8 from Marek Polacek --- Fixed in GCC 11.
[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 --- Comment #7 from CVS Commits --- The master branch has been updated by Marek Polacek : https://gcc.gnu.org/g:21968d4ae067e3fa1c1728c8db26478e8ac8ad0b commit r11-175-g21968d4ae067e3fa1c1728c8db26478e8ac8ad0b Author: Marek Polacek 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.
[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 --- Comment #6 from Marek Polacek --- Patch approved for GCC 11: https://gcc.gnu.org/pipermail/gcc-patches/2020-April/544081.html
[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 Marek Polacek changed: What|Removed |Added Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org --- Comment #5 from Marek Polacek --- Testing a patch.
[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 Marek Polacek changed: What|Removed |Added Status|UNCONFIRMED |NEW CC||mpolacek at gcc dot gnu.org Ever confirmed|0 |1 Last reconfirmed||2020-03-27 --- Comment #4 from Marek Polacek --- Confirmed, started with r0-113135-g28704289327e4295928663b5bab7953718f71bc1
[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 --- Comment #3 from Nicholas Krause --- I've managed to track this down to what appears to me to be a issue in: tree push_inner_scope (tree inner) { tree outer = current_scope (); if (!outer) outer = current_namespace; push_inner_scope_r (outer, inner); return outer; } I'm not certain if we should just check against NULL_TREE for outer or do we need to also check against DECL_NAMESPACE as well. CCing Jason Merrill to take a look at this with his comments.
[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 Nicholas Krause changed: What|Removed |Added CC||jason at redhat dot com, ||xerofoify at gmail dot com --- Comment #2 from Nicholas Krause --- I've managed to track this down to what appears to me to be a issue in: tree push_inner_scope (tree inner) { tree outer = current_scope (); if (!outer) outer = current_namespace; push_inner_scope_r (outer, inner); return outer; } I'm not certain if we should just check against NULL_TREE for outer or do we need to also check against DECL_NAMESPACE as well. CCing Jason Merrill to take a look at this with his comments.
[Bug c++/94255] template specialization in different namespace causes crash
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94255 --- Comment #1 from Vince Bridgers --- The corrected code successfully compiles. Basically, making sure the template specialization is in the correct namespace. namespace clang { class DynTypedNode { private: template struct BaseConverter; template struct ValueConverter {}; }; namespace ast_type_traits { using DynTypedNode = ::clang::DynTypedNode; }; // end namespace ast_type_traits }; // end namespace clang namespace clang { //namespace ast_type_traits { template <> struct DynTypedNode::BaseConverter : public ValueConverter {}; //}; // end namespace ast_type_traits }; // end namespace clang int main(void) { return 0; }