public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/7075: Specialization of template in template does not work
@ 2002-06-19  5:46 rguenth
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth @ 2002-06-19  5:46 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7075
>Category:       c++
>Synopsis:       Specialization of template in template does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 19 04:26:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Richard Guenther
>Release:        gcc 3.1.1 CVS
>Organization:
>Environment:
Linux bellatrix 2.4.18-rc4-TATUP #2 Tue Mar 19 16:30:05 CET 2002 i686 unknown
>Description:
The attached code fails to compile using any version of g++ which complains

part-broken.cpp:10: template parameters not used in partial specialization:
part-broken.cpp:10:         `T'
part-broken.cpp: In static member function `static void foo<T>::bar<d>::blah(T) 
   [with int d = -46, T = int]':

and then fails to use/recognize the specialization, i.e. exceeds maximum template instantiation depth.
>How-To-Repeat:
g++ -c -Wall part-broken.cpp
>Fix:
One can work around this by adding an extra template parameter to the inner class defaulting to the template class of the outer class. See .cpp file.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="part-broken.cpp"
Content-Disposition: inline; filename="part-broken.cpp"

template <typename T>
struct foo {
	/* works, if template <int d, typename X = T> and use X for T */
	template <int d>
	struct bar {
		static void blah(T x)
		{
			bar<d-1>::blah(x);
		}
	};
	struct bar<0> {
		static void blah(T x)
		{
		}
	};
};

int main(int argc, char **argv)
{
	foo<int>::bar<3>::blah(5);
	return 0;
}


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: c++/7075: Specialization of template in template does not work
@ 2002-06-24  7:37 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2002-06-24  7:37 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, rguenth

Synopsis: Specialization of template in template does not work

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Mon Jun 24 07:36:27 2002
State-Changed-Why:
    Not a bug.  According to C++ standard 14.7.3 p18:
      ...the declaration shall not explicitly specialize a
      class member template if its enclosing class are not
      explicitly specialized as well.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7075


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-06-24 14:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-19  5:46 c++/7075: Specialization of template in template does not work rguenth
2002-06-24  7:37 lerdsuwa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).