Bug 15006 - error: too few template-parameter-lists
Summary: error: too few template-parameter-lists
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-18 20:52 UTC by Pawel Sikora
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: pentium3-pld-linux
Target: pentium3-pld-linux
Build: pentium3-pld-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Sikora 2004-04-18 20:52:44 UTC
testcase # http://149.156.124.14/~pluto/tmp/siod.ii 
 
# gcc -v  (fresh build) 
Reading specs from /usr/lib/gcc/pentium3-pld-linux/3.4.0/specs 
Configured with: ../configure --prefix=/usr --libdir=/usr/lib 
--libexecdir=/usr/lib --infodir=/usr/share/info --mandir=/usr/share/man 
--enable-shared --enable-threads=posix --enable-__cxa_atexit 
--enable-languages=c,c++,f77,objc,ada,java --enable-c99 --enable-long-long 
--enable-multilib --enable-nls --with-gnu-as --with-gnu-ld --with-system-zlib 
--with-slibdir=/lib --without-x pentium3-pld-linux 
Thread model: posix 
gcc version 3.4.0 20040416 (prerelease) (PLD Linux)
Comment 1 Andrew Pinski 2004-04-18 21:10:21 UTC
Reduced to:
template<class K, class V> class EST_THash;
class EST_String
{
};
class EST_Regex
{
};
template<class K, class V>
class EST_THash {
private:
  static V Dummy_Value;
  static K Dummy_Key;
};
EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;

But this is invalid.  to explicit instantiation, do the follwoing:
template <> EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
template <> EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;
template  EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
template EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;

But just to define the space for the definition do:
template <> EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
template <> EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;
Comment 2 Beorn Johnson 2005-07-10 19:55:15 UTC
Addendum for those who continue to have difficulty:

I found that the order of the "template ..." vs. "template<> ..." made
a difference, but in linking, not in compiling.  From the previous example:
    template <> EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
    template <> EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;
    template  EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
    template EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;

The (equivalent of the) above would not generate symbols in my '.o', however:
    template  EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
    template EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;
    template <> EST_Regex * EST_THash< EST_String, EST_Regex * >::Dummy_Value;
    template <> EST_String EST_THash< EST_String, EST_Regex * >::Dummy_Key;
will work.   (Note: my case was slightly more complicated, in that instead of "EST_Regex" for the
final type, I had a templated type).  This was in 3.4.2.

Hope this helps.