C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Compile error with template template parameter: is g++ at f

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
xprime@earthlink.net
Guest





PostPosted: Wed Dec 15, 2004 1:37 am    Post subject: Compile error with template template parameter: is g++ at f Reply with quote



Hello C++ coders,

I am trying to compile some code which uses template template
parameters. The code is shown below for reference. This code will
compile with icc, but not with g++. The error message is also
reproduced below.

Is this legal c++ code? It seems that g++ is inappropriately
considering Folderol::operator<<() as a candidate for the function call
at line 23. I say inappropriately because the parameter types are
(intentionally) not even the same between the call and the prototype.
I'm pretty sure the template is at fault, because if I remove it the
program compiles, and with a suitable main function, runs.

This is a distillation of my actual code. It is about as minimal as I
could get it and still produce the error. I googled for the error
message and otherwise attempted to grok this on my own, but I got
nuthin'. Any help would be appreciated.

1
2 #include 3 #include <iostream>
4 #include <sstream>
5 #include <map>
6
7 namespace Folderol
8 {
9 template<template 10 int DEPTH,
11 class ValueType>
12 void operator<<(int &s, const MAP 13 {
14 }
15 }
16
17 namespace Folderol
18 {
19 void foo()
20 {
21 std::string k;
22 std::stringstream message;
23 message << k;
24 }
25 }
26

$ g++ Folderol.cpp
Folderol.cpp: In function `void Folderol::foo()':
Folderol.cpp:23: template argument 3 is invalid

$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
msalters
Guest





PostPosted: Wed Dec 15, 2004 1:02 pm    Post subject: Re: Compile error with template template parameter: is g++ a Reply with quote




[email]xprime (AT) earthlink (DOT) net[/email] wrote:
Quote:
Hello C++ coders,

I am trying to compile some code which uses template template
parameters. The code is shown below for reference. This code will
compile with icc, but not with g++. The error message is also
reproduced below.

Is this legal c++ code? It seems that g++ is inappropriately
considering Folderol::operator<<() as a candidate for the function
call
at line 23. I say inappropriately because the parameter types are
(intentionally) not even the same between the call and the prototype.
I'm pretty sure the template is at fault, because if I remove it the
program compiles, and with a suitable main function, runs.

I don't think it is the only error, but you have only one
operator<< declared in your file. You do include which often but not always includes <ostream>. Your code relies
on an operator<< from and repost the new code and error. Also, which g++ is it?
Regards,
Michiel Salters


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]


Back to top
Mike Davis
Guest





PostPosted: Wed Dec 15, 2004 6:18 pm    Post subject: Re: Compile error with template template parameter: is g++ a Reply with quote



Quote:
So I'd suggest to add <ostream> and repost the new code and error.

Thanks for the suggestion. I included the indicated file and
recompiled. The result was the exact same error message.

Quote:
Also, which g++ is it?

From the orginal post:

$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Thank you very much.

Mike Davis


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Mike Davis
Guest





PostPosted: Wed Dec 15, 2004 6:51 pm    Post subject: Re: Compile error with template template parameter: is g++ a Reply with quote

Quote:
So I'd suggest to add <ostream> and repost the new code and error.

Thanks for the suggestion. I included the indicated file and
recompiled. The result was the exact same error message.

Quote:
Also, which g++ is it?

From the orginal post:

$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--host=i386-redhat-linux
Thread model: posix
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Thank you very much.

Mike Davis


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Ben Hutchings
Guest





PostPosted: Thu Dec 16, 2004 1:41 pm    Post subject: Re: Compile error with template template parameter: is g++ Reply with quote

[email]xprime (AT) earthlink (DOT) net[/email] wrote:
Quote:
Hello C++ coders,

I am trying to compile some code which uses template template
parameters. The code is shown below for reference. This code will
compile with icc, but not with g++. The error message is also
reproduced below.
snip
7 namespace Folderol
8 {
9 template<template 10 int DEPTH,
11 class ValueType
12 void operator<<(int &s, const MAP 13 {
14 }
15 }
16
17 namespace Folderol
18 {
19 void foo()
20 {
21 std::string k;
22 std::stringstream message;
23 message << k;
24 }
25 }
26

$ g++ Folderol.cpp
Folderol.cpp: In function `void Folderol::foo()':
Folderol.cpp:23: template argument 3 is invalid

This is a compiler bug. Specialisation failure is not an error
(SFINAE) and should simply eliminate your operator<< template from
consideration.

Quote:
$ g++ -v
snip
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Try upgrading to 3.4.

--
Ben Hutchings
If at first you don't succeed, you're doing about average.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Ben Hutchings
Guest





PostPosted: Fri Dec 17, 2004 4:41 am    Post subject: Re: Compile error with template template parameter: is g++ Reply with quote

I wrote:
Quote:
xprime (AT) earthlink (DOT) net wrote:
snip
$ g++ Folderol.cpp
Folderol.cpp: In function `void Folderol::foo()':
Folderol.cpp:23: template argument 3 is invalid

This is a compiler bug. Specialisation failure is not an error
(SFINAE) and should simply eliminate your operator<< template from
consideration.

$ g++ -v
snip
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Try upgrading to 3.4.

This seems to be broken in 3.4.3 still, though a similar bug was
fixed:
--
Ben Hutchings
This sentence contradicts itself - no actually it doesn't.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Ben Hutchings
Guest





PostPosted: Fri Dec 17, 2004 3:09 pm    Post subject: Re: Compile error with template template parameter: is g++ Reply with quote

I wrote:
Quote:
I wrote:
[email]xprime (AT) earthlink (DOT) net[/email] wrote:
snip
$ g++ Folderol.cpp
Folderol.cpp: In function `void Folderol::foo()':
Folderol.cpp:23: template argument 3 is invalid

This is a compiler bug. Specialisation failure is not an error
(SFINAE) and should simply eliminate your operator<< template from
consideration.

$ g++ -v
snip
gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)

Try upgrading to 3.4.

This seems to be broken in 3.4.3 still, though a similar bug was
fixed:

Sorry to have to post again, but the bug you found has been reported
as <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17344, fixed in the
development version, and should be gone in versions 3.4.4 and 4.0.0.

--
Ben Hutchings
73.46% of all statistics are made up.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Mike Davis
Guest





PostPosted: Tue Dec 21, 2004 10:21 am    Post subject: Re: Compile error with template template parameter: is g++ a Reply with quote

Quote:
Sorry to have to post again, but the bug you found has been reported
as <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17344, fixed in the
development version, and should be gone in versions 3.4.4 and 4.0.0.

Thanks for the continuing followups. As soon as I get back to work
after the holidays, I'll test 3.4.4 and/or 4.0.0.

Regards,

Mike Davis


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.