gcc-4.1 crashes on templated class with a member function as argument with member function type default value assigned as template parameter default value

Bug #226718 reported by frostiebek
2
Affects Status Importance Assigned to Milestone
gcc-4.1 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: gcc-4.1

G++-4.1 on ubuntu does not seem to handle the following functionality of C++ templated classes.
The error message given is :
test00.cpp:58: internal compiler error: in uses_template_parms, at cp/pt.c:5084
NOTE: G++-4.2 won't report any error, and won't build the source (like 3.4)

template <typename C, typename T>
struct Delegate
{
typedef void (C::*type)(T& outValue);
};

template <typename C, typename T,
  typename Delegate<C, T>::type IF_NEEDED = typename Delegate<C, T>::type() >
struct Member
{
   T& FValue;
   C& FOwner;
   Member(C& parOwner) : FValue (), FOwner (parOwner) {}
   T& Read() { if (IF_NEEDED != typename Delegate<C, T>::type()) (FOwner.*IF_NEEDED)(FValue); return (FValue); }
};

ProblemType: Crash
Architecture: i386
Date: Mon May 5 03:05:44 2008
DistroRelease: Ubuntu 8.04
ExecutablePath: /usr/lib/gcc/i486-linux-gnu/4.1.3/cc1plus
Package: g++-4.1 4.1.2-21ubuntu1
PackageArchitecture: i386
SourcePackage: gcc-4.1
Uname: Linux 2.6.24-16-generic i686

Tags: apport-crash
Revision history for this message
frostiebek (phamtom-x) wrote :
Revision history for this message
Matthias Klose (doko) wrote :

the ICE is fixed in gcc-4.2 (hardy) and gcc-4.3 (intrepid).

$ g++ -Wall test00.cpp
test00.cpp:57: error: a cast to a type other than an integral or enumeration type cannot appear in a constant-expression
test00.cpp:57: error: template argument 3 is invalid
test00.cpp:65: error: a cast to a type other than an integral or enumeration type cannot appear in a constant-expression
test00.cpp:65: error: template argument 3 is invalid
test00.cpp: In instantiation of 'TSlot<int>':
test00.cpp:61: instantiated from here
test00.cpp:43: error: 'int' is not a class, struct, or union type
test00.cpp:44: error: 'int' is not a class, struct, or union type
test00.cpp:45: error: 'int' is not a class, struct, or union type
test00.cpp:47: error: 'int' is not a class, struct, or union type
test00.cpp:49: error: 'int' is not a class, struct, or union type
test00.cpp:51: error: 'int' is not a class, struct, or union type
test00.cpp:52: error: 'int' is not a class, struct, or union type
test00.cpp: In static member function 'static const TSlot<int>& Test::SlotName()':
test00.cpp:61: error: no matching function for call to 'TSlot<int>::TSlot(int Test::*)'
test00.cpp:41: note: candidates are: TSlot<int>::TSlot(const TSlot<int>&)
test00.cpp: In static member function 'static const TSlot<int>& Test::SlotAge()':
test00.cpp:69: error: no matching function for call to 'TSlot<int>::TSlot(int Test::*)'
test00.cpp:41: note: candidates are: TSlot<int>::TSlot(const TSlot<int>&)
test00.cpp: In constructor 'Test::Test()':
test00.cpp:73: error: cannot convert 'Test' to 'int' in initialization
test00.cpp:73: error: cannot convert 'Test' to 'int' in initialization
test00.cpp: In function 'int main()':
test00.cpp:83: error: cannot convert 'std::string' to 'int' in assignment
test00.cpp:85: error: invalid type argument of 'unary *'
test00.cpp:85: error: invalid type argument of 'unary *'
test00.cpp:87: error: invalid conversion from 'int' to 'const char*'
test00.cpp:87: error: initializing argument 1 of 'std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]'

Changed in gcc-4.1:
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.