I am using gcc (GCC) 3.3.1 (Mandrake Linux 9.2 3.3.1-2mdk) I've recreated code that produces the conditions I had in my main project. I don't know if I can reduce the size anymore. The error: tpl_mangle.cc: In function `int main()': tpl_mangle.cc:30: internal compiler error: in write_unscoped_name, at cp/mangle.c:786 Attached is code that produces the error. I've found Bug 9304 and 10428 which both produce the same error, but do not involve templates and namespaces. (Will attach code)
Created attachment 6635 [details] Reproduction code
Confirmed.
Here's a redux: --------------------- namespace io { template <typename> int foo(); } using namespace io; template<> int foo<int>(); int a = foo<int>(); ------------------- g/x> /home/bangerth/bin/gcc-3.5-pre/bin/c++ -c x.cc x.cc:9: internal compiler error: in write_unscoped_name, at cp/mangle.c:832 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. The code is invalid, though: you can't declare the existence of a specialization of foo() in global namespace without declaring the existence of a general template first. It does not correspond to the general template in namespace io. W.
Agreed. The redux and my original code are invalid, putting the template specialization in its proper namespace removes the error.
Working on a fix.
Subject: Bug 16224 CVSROOT: /cvs/gcc Module name: gcc Changes by: mmitchel@gcc.gnu.org 2004-08-02 06:25:37 Modified files: gcc/cp : ChangeLog name-lookup.c pt.c gcc/testsuite : ChangeLog gcc/testsuite/g++.old-deja/g++.ns: template13.C gcc/testsuite/g++.old-deja/g++.pt: lookup10.C Added files: gcc/testsuite/g++.dg/template: spec17.C Log message: PR c++/16224 * name-lookup.c (decl_namespace): Remove. (current_decl_namespace): Use decl_namespace_context instead of decl_namespace. (push_decl_namespace): Likewise. (arg_assoc_class): Likewise. (arg_assoc_type): Likewise. * pt.c (check_specialization_namespace): New function. (maybe_process_partial_specialization): Use it. (register_specialization): Likewise. PR c++/16224 * g++.dg/template/spec17.C: New test. * g++.old-deja/g++.ns/template13.C: Remove XFAIL. * g++.old-deja/g++.pt/lookup10.C: Add dg-error marker. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.4257&r2=1.4258 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&r1=1.79&r2=1.80 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&r1=1.899&r2=1.900 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.4083&r2=1.4084 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec17.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.ns/template13.C.diff?cvsroot=gcc&r1=1.6&r2=1.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.pt/lookup10.C.diff?cvsroot=gcc&r1=1.2&r2=1.3
Subject: Bug 16224 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_4-branch Changes by: mmitchel@gcc.gnu.org 2004-08-02 06:26:25 Modified files: gcc/cp : ChangeLog name-lookup.c pt.c gcc/testsuite : ChangeLog gcc/testsuite/g++.old-deja/g++.ns: template13.C gcc/testsuite/g++.old-deja/g++.pt: lookup10.C Added files: gcc/testsuite/g++.dg/template: spec17.C Log message: PR c++/16224 * name-lookup.c (decl_namespace): Remove. (current_decl_namespace): Use decl_namespace_context instead of decl_namespace. (push_decl_namespace): Likewise. (arg_assoc_class): Likewise. (arg_assoc_type): Likewise. * pt.c (check_specialization_namespace): New function. (maybe_process_partial_specialization): Use it. (register_specialization): Likewise. PR c++/16224 * g++.dg/template/spec17.C: New test. * g++.old-deja/g++.ns/template13.C: Remove XFAIL. * g++.old-deja/g++.pt/lookup10.C: Add dg-error marker. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3892.2.139&r2=1.3892.2.140 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/name-lookup.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.34.2.16&r2=1.34.2.17 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/pt.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.816.2.35&r2=1.816.2.36 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.3389.2.240&r2=1.3389.2.241 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/spec17.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=NONE&r2=1.1.2.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.ns/template13.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.6&r2=1.6.16.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.pt/lookup10.C.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.2&r2=1.2.16.1
Fixed in GCC 3.4.2 and GCC 3.5.