This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13520] New: gcc crashes with inheritance + default template parameter of nested template type
- From: "hetadres at email dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 30 Dec 2003 12:58:14 -0000
- Subject: [Bug c++/13520] New: gcc crashes with inheritance + default template parameter of nested template type
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
g++ crashes when instanciating template class Host in the following code.
----------
template<typename regular_type> class Policy {};
template <
typename regular_type,
template<typename> class OriginalPolicy
>
class ChangedPolicy_impl {};
template <template<typename> class OriginalPolicy > class ChangedPolicy {
public:
template<typename regular_type> class Type : public
ChangedPolicy_impl<regular_type,OriginalPolicy> { };
};
template <
typename regular_type,
template<typename> class Policy1,
template<typename> class Policy2 = ChangedPolicy<Policy1>::Type
> class Host : public Policy1<regular_type>,
public Policy2<regular_type> { };
int main() {
Host<void, Policy>h;
return 0;
}
----------
$ gcc -c try.cxx
try.cxx: In instantiation of `Host<void, Policy, ChangedPolicy<OriginalPolicy>::
Type>':
try.cxx:26: instantiated from here
try.cxx:22: internal error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://bugs.gentoo.org/> for instructions.
I'm not absolutely sure about line 20 ("template<typename> class Policy2 =
ChangedPolicy<Policy1>::Type"), maybe it should be "template<typename> class
Policy2 = typename ChangedPolicy<Policy1>::Type". But then gcc says:
try.cxx:21: `template<template<class> class OriginalPolicy> template<class
regular_type> class ChangedPolicy<OriginalPolicy>::Type' used without
template parameters
try.cxx:21: ISO C++ forbids declaration of `type name' with no type
try.cxx:21: invalid default template argument
try.cxx: In function `int main()':
try.cxx:26: template argument 3 is invalid
try.cxx:26: ISO C++ forbids declaration of `h' with no type
I need this code to be working, because i have to hand it in at the University
of Antwerp next month :-/
Thanks for your help.
--
Summary: gcc crashes with inheritance + default template
parameter of nested template type
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hetadres at email dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13520