public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/17445] New: too few template-parameter-lists
@ 2004-09-13 0:39 carlson14 at llnl dot gov
2004-09-13 1:03 ` [Bug c++/17445] " pinskia at gcc dot gnu dot org
` (13 more replies)
0 siblings, 14 replies; 15+ messages in thread
From: carlson14 at llnl dot gov @ 2004-09-13 0:39 UTC (permalink / raw)
To: gcc-bugs
The following code give this error (compiles fine in 3.3.3):
I don't know if I need to fix my code, or if it is a bug
in 3.4.1.
test.cpp:10: error: too few template-parameter-lists
test.cpp:10: error: expected `,' or `;' before '=' token
template <class T> class MyType {
public:
static char *name;
};
class Sample {
};
MyType<Sample> list;
char *MyType<Sample>::name = "Hello\n";
int main(int argc, char **argv) {
}
gcc -v -save-temps test.cpp
Reading specs
from /usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../lib/gcc/alphaev67-
dec-osf5.1/3.4.1/specs
Configured with: /usr/global/src/gnu/gcc/gcc-3.4.1/configure --
prefix=/usr/local/tools/gnu/gcc/3.4.1_tru64_5
Thread model: posix
gcc version 3.4.1
/usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../libexec/gcc/alphaev67-
dec-osf5.1/3.4.1/cc1plus -E -quiet -v -
iprefix /usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../lib/gcc/alphaev67-
dec-osf5.1/3.4.1/ test.cpp -mcpu=ev67 -o test.ii
ignoring nonexistent
directory "/usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../lib/gcc/alphaev
67-dec-osf5.1/3.4.1/../../../../alphaev67-dec-osf5.1/include"
ignoring duplicate
directory "/usr/local/tools/gnu/gcc/3.4.1_tru64_5/lib/gcc/alphaev67-dec-
osf5.1/3.4.1/../../../../include/c++/3.4.1"
ignoring duplicate
directory "/usr/local/tools/gnu/gcc/3.4.1_tru64_5/lib/gcc/alphaev67-dec-
osf5.1/3.4.1/../../../../include/c++/3.4.1/alphaev67-dec-osf5.1"
ignoring duplicate
directory "/usr/local/tools/gnu/gcc/3.4.1_tru64_5/lib/gcc/alphaev67-dec-
osf5.1/3.4.1/../../../../include/c++/3.4.1/backward"
ignoring duplicate
directory "/usr/local/tools/gnu/gcc/3.4.1_tru64_5/lib/gcc/alphaev67-dec-
osf5.1/3.4.1/include"
ignoring nonexistent
directory "/usr/local/tools/gnu/gcc/3.4.1_tru64_5/lib/gcc/alphaev67-dec-
osf5.1/3.4.1/../../../../alphaev67-dec-osf5.1/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../lib/gcc/alphaev67-dec-
osf5.1/3.4.1/../../../../include/c++/3.4.1
/usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../lib/gcc/alphaev67-dec-
osf5.1/3.4.1/../../../../include/c++/3.4.1/alphaev67-dec-osf5.1
/usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../lib/gcc/alphaev67-dec-
osf5.1/3.4.1/../../../../include/c++/3.4.1/backward
/usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../lib/gcc/alphaev67-dec-
osf5.1/3.4.1/include
/usr/local/include
/usr/local/tools/gnu/gcc/3.4.1_tru64_5/include
/usr/include
End of search list.
/usr/local/tools/openSource/gcc/3.4.1_tru64_5/bin/../libexec/gcc/alphaev67-
dec-osf5.1/3.4.1/cc1plus -fpreprocessed test.ii -quiet -dumpbase test.cpp -
mcpu=ev67 -auxbase test -version -o test.s
GNU C++ version 3.4.1 (alphaev67-dec-osf5.1)
compiled by GNU C version 3.3.3.
GGC heuristics: --param ggc-min-expand=57 --param ggc-min-heapsize=51200
--
Summary: too few template-parameter-lists
Product: gcc
Version: 3.4.1
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: carlson14 at llnl dot gov
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: alphaev67-dec-osf5.1
GCC host triplet: alphaev67-dec-osf5.1
GCC target triplet: alphaev67-dec-osf5.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
@ 2004-09-13 1:03 ` pinskia at gcc dot gnu dot org
2004-09-13 1:03 ` pinskia at gcc dot gnu dot org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-13 1:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-13 01:03 -------
You want:
template<>
MyType<Sample> list;
char *MyType<Sample>::name = "Hello\n";
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
2004-09-13 1:03 ` [Bug c++/17445] " pinskia at gcc dot gnu dot org
@ 2004-09-13 1:03 ` pinskia at gcc dot gnu dot org
2005-04-18 6:38 ` leslie dot barnes at amd dot com
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-13 1:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-09-13 01:03 -------
*** Bug 17446 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
2004-09-13 1:03 ` [Bug c++/17445] " pinskia at gcc dot gnu dot org
2004-09-13 1:03 ` pinskia at gcc dot gnu dot org
@ 2005-04-18 6:38 ` leslie dot barnes at amd dot com
2005-04-18 9:08 ` giovannibajo at libero dot it
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: leslie dot barnes at amd dot com @ 2005-04-18 6:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From leslie dot barnes at amd dot com 2005-04-18 06:38 -------
(In reply to comment #2)
> You want:
> template<>
> MyType<Sample> list;
> char *MyType<Sample>::name = "Hello\n";
The following code seg faults with g++ 3.4.3. If I remove the "template <>",
it won't compile. On g++ 3.3, without the "template <>" it is happy and prints
"goodbye". With the "template <>" it also seg faults.
I'd like to know if this is a bug, or my inability to figure out the correct
syntax.
thanks
#include <cstdio>
#include <map>
template <class T> class MyType {
public:
static std::map<char*,char*> m_map;
};
class Sample {
};
template class MyType<Sample>;
template <> std::map<char*,char*> MyType<Sample>::m_map;
int main(int argc, char **argv) {
MyType<Sample>::m_map["hello"]="goodbye";
printf("%s\n",MyType<Sample>::m_map["hello"]);
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (2 preceding siblings ...)
2005-04-18 6:38 ` leslie dot barnes at amd dot com
@ 2005-04-18 9:08 ` giovannibajo at libero dot it
2005-04-18 13:37 ` leslie dot barnes at amd dot com
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: giovannibajo at libero dot it @ 2005-04-18 9:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2005-04-18 09:08 -------
A segfault in GCC is always a bug, even if the code is wrong. Would you please
open a new bugreport about it?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (3 preceding siblings ...)
2005-04-18 9:08 ` giovannibajo at libero dot it
@ 2005-04-18 13:37 ` leslie dot barnes at amd dot com
2005-04-18 20:16 ` bangerth at dealii dot org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: leslie dot barnes at amd dot com @ 2005-04-18 13:37 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From leslie dot barnes at amd dot com 2005-04-18 13:37 -------
(In reply to comment #4)
> A segfault in GCC is always a bug, even if the code is wrong. Would you please
> open a new bugreport about it?
Sorry, I wasn't clear. The binary seg faults, not the compiler.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (4 preceding siblings ...)
2005-04-18 13:37 ` leslie dot barnes at amd dot com
@ 2005-04-18 20:16 ` bangerth at dealii dot org
2005-04-19 0:02 ` leslie dot barnes at amd dot com
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2005-04-18 20:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-04-18 20:16 -------
This code has at least two bugs:
template class MyType<Sample>;
template <> std::map<char*,char*> MyType<Sample>::m_map;
First, the instantiation must come *after* the definition of the static
member.
Second, the definition you thought you have written is in fact only the
declaration of an explicit specialization of that member. It needs an
initializer. You need to write
template <> std::map<char*,char*> MyType<Sample>::m_map
= std::map<char*,char*>();
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (5 preceding siblings ...)
2005-04-18 20:16 ` bangerth at dealii dot org
@ 2005-04-19 0:02 ` leslie dot barnes at amd dot com
2005-04-19 14:08 ` bangerth at dealii dot org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: leslie dot barnes at amd dot com @ 2005-04-19 0:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From leslie dot barnes at amd dot com 2005-04-19 00:02 -------
(In reply to comment #6)
> This code has at least two bugs:
>
> template class MyType<Sample>;
> template <> std::map<char*,char*> MyType<Sample>::m_map;
>
> First, the instantiation must come *after* the definition of the static
> member.
> Second, the definition you thought you have written is in fact only the
> declaration of an explicit specialization of that member. It needs an
> initializer. You need to write
>
> template <> std::map<char*,char*> MyType<Sample>::m_map
> = std::map<char*,char*>();
>
> W.
>
(In reply to comment #6)
> This code has at least two bugs:
>
> template class MyType<Sample>;
> template <> std::map<char*,char*> MyType<Sample>::m_map;
>
> First, the instantiation must come *after* the definition of the static
> member.
> Second, the definition you thought you have written is in fact only the
> declaration of an explicit specialization of that member. It needs an
> initializer. You need to write
>
> template <> std::map<char*,char*> MyType<Sample>::m_map
> = std::map<char*,char*>();
>
> W.
>
Great, thanks! If someone could put this on the g++ 3.4.3 changes page, that
would probably save people quite a bit of time.
http://www.gnu.org/software/gcc/gcc-3.4/changes.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (6 preceding siblings ...)
2005-04-19 0:02 ` leslie dot barnes at amd dot com
@ 2005-04-19 14:08 ` bangerth at dealii dot org
2005-04-25 4:10 ` pinskia at gcc dot gnu dot org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2005-04-19 14:08 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-04-19 14:08 -------
Why? This code as always wrong. It has nothing to do with gcc3.4.x.
W.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (7 preceding siblings ...)
2005-04-19 14:08 ` bangerth at dealii dot org
@ 2005-04-25 4:10 ` pinskia at gcc dot gnu dot org
2005-04-25 4:13 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 4:10 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-25 04:09 -------
*** Bug 21200 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |iguchi at coral dot t dot u-
| |tokyo dot ac dot jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (8 preceding siblings ...)
2005-04-25 4:10 ` pinskia at gcc dot gnu dot org
@ 2005-04-25 4:13 ` pinskia at gcc dot gnu dot org
2005-04-25 4:15 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 4:13 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-25 04:12 -------
*** Bug 11930 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |schnetter at uni-tuebingen
| |dot de
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (9 preceding siblings ...)
2005-04-25 4:13 ` pinskia at gcc dot gnu dot org
@ 2005-04-25 4:15 ` pinskia at gcc dot gnu dot org
2005-04-25 4:19 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 4:15 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-25 04:12 -------
*** Bug 14891 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |gabriele dot greco at darts
| |dot it
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (10 preceding siblings ...)
2005-04-25 4:15 ` pinskia at gcc dot gnu dot org
@ 2005-04-25 4:19 ` pinskia at gcc dot gnu dot org
2005-07-28 18:51 ` owen at titan dot com
2005-07-28 19:54 ` bangerth at dealii dot org
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-25 4:19 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-04-25 04:11 -------
*** Bug 11585 has been marked as a duplicate of this bug. ***
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |mueller at kde dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (11 preceding siblings ...)
2005-04-25 4:19 ` pinskia at gcc dot gnu dot org
@ 2005-07-28 18:51 ` owen at titan dot com
2005-07-28 19:54 ` bangerth at dealii dot org
13 siblings, 0 replies; 15+ messages in thread
From: owen at titan dot com @ 2005-07-28 18:51 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From owen at titan dot com 2005-07-28 18:47 -------
>From Wolfgang Bangerth:
You need to write:
template <> std::map<char*,char*> MyType<Sample>::m_map
= std::map<char*,char*>();
My problem with this is that it requires that the static member support the copy
constructor. In my case, the static member is something that cannot be copied,
so I put an explicit copy constructor into the private section of my template
class, which makes the above statement generate an error that the copy
constructor is private. How do I instantiate this static member? It's default
constructor does all the initialization I want, and I don't want that
initialization done twice.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/17445] too few template-parameter-lists
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
` (12 preceding siblings ...)
2005-07-28 18:51 ` owen at titan dot com
@ 2005-07-28 19:54 ` bangerth at dealii dot org
13 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2005-07-28 19:54 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-07-28 19:43 -------
I believe you can't.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17445
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2005-07-28 19:43 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-13 0:39 [Bug c++/17445] New: too few template-parameter-lists carlson14 at llnl dot gov
2004-09-13 1:03 ` [Bug c++/17445] " pinskia at gcc dot gnu dot org
2004-09-13 1:03 ` pinskia at gcc dot gnu dot org
2005-04-18 6:38 ` leslie dot barnes at amd dot com
2005-04-18 9:08 ` giovannibajo at libero dot it
2005-04-18 13:37 ` leslie dot barnes at amd dot com
2005-04-18 20:16 ` bangerth at dealii dot org
2005-04-19 0:02 ` leslie dot barnes at amd dot com
2005-04-19 14:08 ` bangerth at dealii dot org
2005-04-25 4:10 ` pinskia at gcc dot gnu dot org
2005-04-25 4:13 ` pinskia at gcc dot gnu dot org
2005-04-25 4:15 ` pinskia at gcc dot gnu dot org
2005-04-25 4:19 ` pinskia at gcc dot gnu dot org
2005-07-28 18:51 ` owen at titan dot com
2005-07-28 19:54 ` bangerth at dealii dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).