This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/5767: <synopsis of the problem (one line)>Forwarding template template parameters



>Number:         5767
>Category:       c++
>Synopsis:       Forwarding template template parameters
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 23 19:16:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Andreas Priesnitz
>Release:        3.0.4
>Organization:
>Environment:
System: OSF1 u51.num.math.uni-goettingen.de V4.0 1229 alpha
Machine: alpha
	
host: alphaev67-dec-osf4.0f
build: alphaev67-dec-osf4.0f
target: alphaev67-dec-osf4.0f
configured with: /tmp_mnt/home/cfd1/home/cfd/gcc-3.0.4/configure --prefix=/home/cfd1/usr --exec-prefix=/home/cfd1/usr/alphaev67-dec-osf4.0f --srcdir=/tmp_mnt/home/cfd1/home/cfd/gcc-3.0.4 --enable-static --enable-shared --disable-nls --without-gnu-as --without-gnu-ld --enable-languages=c++ --enable-cpp --enable-multilib --disable-threads --disable-libgcj --disable-target-optspace --with-stabs --without-dwarf2
>Description:
	
g++ crashes for this example of forwarding template template parameters.
`A<TP>::template Template' is what I would expect, but gives a parse error.

% g++ bug.cc
bug.cc: In function `int main()':
bug.cc:29: Internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
>How-To-Repeat:
	
template <template <typename> class TP>
struct A
{
    template <typename T>
    struct Template
    {
	typedef typename TP<T>::Type Type;
    };
};
template <template <typename> class TP>
struct B
{
    template <typename T>
    struct Template
    {
	// Using `template' qualifier before first `Template' gives parse error
	typedef typename A<A<TP>::Template>::template Template<T>::Type Type;
    };
};
template <typename T>
struct C
{
    typedef void Type;
};
int main()
{
    typedef B<C>::Template<void>::Type Type;
}
>Fix:
	
Use wrappers (works, but means clumsy code):

template <class W>
struct A
{
    struct Wrapper
    {
	template <typename T>
	struct Template
	{
	    typedef typename W::template Template<T>::Type Type;
	};
    };
};
template <template <typename> class TP>
struct B
{
    struct Wrapper
    {
	template <typename T>
	struct Template
	{
	    typedef typename TP<T>::Type Type;
	};
    };
    template <typename T>
    struct Template
    {
	typedef typename A<typename A<Wrapper>::Wrapper>::Wrapper::template Template<T>::Type Type;
    };
};
template <typename T>
struct C
{
    typedef void Type;
};
int main()
{
    typedef B<C>::Template<void>::Type Type;
}
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]