[Bug c++/24648] New: a template parse error

2005-11-02 Thread hwon at 21cn dot com
//==code==
#include 
#include 
#include 
#include 

using namespace std;

template
struct testClass
{
typedef hash_map IntHashMap;
typedef list KList;
IntHashMap hm;
KList kl;

void operator()(K k)
{
hm[k] = 999;
IntHashMap::iterator itr = hm.find(k);
cout << itr->second << endl;

kl.push_back(k);
KList::iterator it = kl.begin();
cout << endl << *it << endl;
}
};

int main()
{
testClass tc;
tc(111);
}


//==compile error==
test.cpp: In member function `void testClass::operator()(K)':
test.cpp:19: error: expected `;' before "itr"
test.cpp:20: error: `itr' undeclared (first use this function)
test.cpp:20: error: (Each undeclared identifier is reported only once for each
function it appears in.)
test.cpp:23: error: expected `;' before "it"
test.cpp:24: error: `it' undeclared (first use this function)
test.cpp: In member function `void testClass::operator()(K) [with K = int]':
test.cpp:31:   instantiated from here
test.cpp:19: error: dependent-name `
__gnu_cxx::hash_map,std::equal_to<_Key>,std::allocator
>::iterator' is parsed as a non-type, but instantiation yields a type
test.cpp:19: note: say `typename 
__gnu_cxx::hash_map,std::equal_to<_Key>,std::allocator
>::
iterator' if a type is meant
test.cpp:31:   instantiated from here
test.cpp:23: error: dependent-name ` std::list
>::iterator' is parsed as a non-type, but instantiati
on yields a type
test.cpp:23: note: say `typename  std::list
>::iterator' if a type is meant


-- 
   Summary: a template parse error
   Product: gcc
   Version: 3.4.4
Status: UNCONFIRMED
  Severity: major
      Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hwon at 21cn dot com
  GCC host triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24648



[Bug c++/24648] a template parse error

2005-11-02 Thread hwon at 21cn dot com


--- Comment #1 from hwon at 21cn dot com  2005-11-03 04:32 ---
It compile ok under gcc 2.95.
But errors under gcc 3.4.2/3.4.4


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24648