Bug 10849 - [3.3 regression] Cannot define an out-of-class specialization of a private nested template class
Summary: [3.3 regression] Cannot define an out-of-class specialization of a private ne...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.3.1
: P3 normal
Target Milestone: 3.3.1
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: rejects-valid
: 10854 10887 10969 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-05-18 21:56 UTC by Giovanni Bajo
Modified: 2003-07-10 13:43 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-06 10:47:26


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Giovanni Bajo 2003-05-18 21:56:00 UTC
Reported by Ole Laursen here:
http://gcc.gnu.org/ml/gcc/2003-05/msg01686.html

---------------------------------------------
class X
{
private:
    template <typename T> struct Y;
};

template <> 
struct X::Y<int>
{};
---------------------------------------------
gccbug5.cpp:4: error: `template<class T> struct X::Y' is private
gccbug5.cpp:9: error: within this context

Regression on the 3.3 branch and mainline (3.2.2 and 2.95
worked fine).

Release:
3.3 and 3.4 (CVS 20030503)

Environment:
i686-pc-cygwin

How-To-Repeat:
Compile the above snippet
Comment 1 Giovanni Bajo 2003-05-18 22:08:52 UTC
Responsible-Changed-From-To: unassigned->lerdsuwa
Responsible-Changed-Why: Kriang said that he will take care of this.
Comment 2 Giovanni Bajo 2003-05-18 22:08:52 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Already analyzed by Gaby and Kriang, and reconfirmed by me.
Comment 3 Kriang Lerdsuwanakij 2003-05-24 17:54:04 UTC
Patch submitted:

  http://gcc.gnu.org/ml/gcc-patches/2003-05/msg02152.html
Comment 4 Kriang Lerdsuwanakij 2003-05-24 17:58:48 UTC
*** Bug 10969 has been marked as a duplicate of this bug. ***
Comment 5 Kriang Lerdsuwanakij 2003-05-25 10:35:07 UTC
Fixed in the 3.3 branch.
Comment 6 Debian GCC Maintainers 2003-06-29 08:44:29 UTC
[forwarded from http://bugs.debian.org/193830]

fyi,  
 
gcc version 3.3.1 20030626 (Debian prerelease) 
(aka '3.3.1-0pre0' in debian) 
 
improves a bit on the situation: 
 
class Foo { 
  template <class T> struct InFoo; 
  template <class T, class U> struct InFoo2; 
}; 
 
template<> 
struct Foo::InFoo<int> { 
  // ...this works now... (didn't work with 3.3.0) 
}; 
 
template<class T> 
struct Foo::InFoo2<T, int> { 
  // ...this still triggers error 
}; 

Comment 7 Giovanni Bajo 2003-06-29 08:57:59 UTC
Confirmed. Kriang, your 3.3 workaround is not complete because 
processing_specialization is set only for explicit specializations, not for 
partial specializations.
Comment 8 Kriang Lerdsuwanakij 2003-07-06 10:47:25 UTC
Look like it needs a real fix, not just my workaround.
Comment 9 Kriang Lerdsuwanakij 2003-07-07 15:14:39 UTC
Patch submitted:

  http://gcc.gnu.org/ml/gcc-patches/2003-07/msg00693.html
Comment 10 CVS Commits 2003-07-10 12:43:20 UTC
Subject: Bug 10849

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	lerdsuwa@gcc.gnu.org	2003-07-10 12:43:17

Modified files:
	gcc/cp         : ChangeLog cp-tree.h decl2.c parse.y search.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: access12.C 

Log message:
	PR c++/10849
	* decl2.c (handle_class_head_apparent_template): New function.
	* cp-tree.h (handle_class_head_apparent_template): Add declaration.
	* parse.y (class_head_defn): Use it.
	* search.c (type_access_control): Revert my 2003-05-25 change.
	
	* g++.dg/template/access12.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.3076.2.176&r2=1.3076.2.177
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.776.2.24&r2=1.776.2.25
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl2.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.575.2.33&r2=1.575.2.34
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parse.y.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.284.2.6&r2=1.284.2.7
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/search.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.243.2.12&r2=1.243.2.13
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.223&r2=1.2261.2.224
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/access12.C.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 11 CVS Commits 2003-07-10 12:48:20 UTC
Subject: Bug 10849

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	lerdsuwa@gcc.gnu.org	2003-07-10 12:48:17

Modified files:
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/g++.dg/template: access12.C 

Log message:
	PR c++/10849
	* g++.dg/template/access12.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2857&r2=1.2858
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/template/access12.C.diff?cvsroot=gcc&r1=1.1&r2=1.2

Comment 12 Kriang Lerdsuwanakij 2003-07-10 13:43:38 UTC
Fixed.