Bug 16224 - [3.3/3.4/4.0 Regression] internal compiler error: in write_unscoped_name (template/namespace)
Summary: [3.3/3.4/4.0 Regression] internal compiler error: in write_unscoped_name (tem...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.4.2
Assignee: Mark Mitchell
URL:
Keywords: ABI, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2004-06-27 06:48 UTC by eda-qa
Modified: 2004-10-07 23:42 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 2.95.3
Known to fail: 3.0.4 3.4.0 4.0.0 3.3.3 3.2.3
Last reconfirmed: 2004-06-27 08:42:35


Attachments
Reproduction code (175 bytes, text/plain)
2004-06-27 06:50 UTC, eda-qa
Details

Note You need to log in before you can comment on or make changes to this bug.
Description eda-qa 2004-06-27 06:48:59 UTC
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)
Comment 1 eda-qa 2004-06-27 06:50:31 UTC
Created attachment 6635 [details]
Reproduction code
Comment 2 Andrew Pinski 2004-06-27 08:42:35 UTC
Confirmed.
Comment 3 Wolfgang Bangerth 2004-06-27 21:22:53 UTC
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. 
Comment 4 eda-qa 2004-06-28 05:40:43 UTC
Agreed.  The redux and my original code are invalid, putting the template
specialization in its proper namespace removes the error.
Comment 5 Mark Mitchell 2004-08-02 02:33:19 UTC
Working on a fix.
Comment 6 GCC Commits 2004-08-02 06:25:44 UTC
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

Comment 7 GCC Commits 2004-08-02 06:26:28 UTC
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

Comment 8 Mark Mitchell 2004-08-02 06:27:14 UTC
Fixed in GCC 3.4.2 and GCC 3.5.