public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13879] New: Error when doing an explicit specilization within a class
@ 2004-01-27 9:31 lifshitz at post dot tau dot ac dot il
2004-01-27 15:35 ` [Bug c++/13879] " pinskia at gcc dot gnu dot org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: lifshitz at post dot tau dot ac dot il @ 2004-01-27 9:31 UTC (permalink / raw)
To: gcc-bugs
code is (in file fact.cc):
// meta factorial - example for generative programming by James O. Coplien
// the Test class was added to demonstrate the gcc compilation error.
#include <stdio.h>
class Test {
public:
template<int n>
struct Fact
{
enum {RET = Fact<n-1>::RET*n};
};
template<>
struct Fact<0>
{
enum{RET = 1};
};
void Print()
{
printf("Fact<7>=%d\n", Fact<7>::RET);
}
};
int main()
{
Test t;
t.Print();
return 0;
}
command line:
gcc fact.cc
compilation error:
fact.cc:14: explicit specialization in non-namespace scope 'Test'
Note: the same code was compiled using sun compiler:
cc fact.cc
Both compilation and execution were successful.
--
Summary: Error when doing an explicit specilization within a
class
Product: gcc
Version: 2.95.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: lifshitz at post dot tau dot ac dot il
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: sparc-ultra5_10-sunOS5.8
GCC host triplet: sparc-ultra5_10-sunOS5.8
GCC target triplet: sparc-ultra5_10-sunOS5.8
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13879
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/13879] Error when doing an explicit specilization within a class
2004-01-27 9:31 [Bug c++/13879] New: Error when doing an explicit specilization within a class lifshitz at post dot tau dot ac dot il
@ 2004-01-27 15:35 ` pinskia at gcc dot gnu dot org
2004-01-28 5:58 ` lifshitz at post dot tau dot ac dot il
2004-01-28 6:05 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-27 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-01-27 15:35 -------
Not a bug, the error message is correct.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13879
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/13879] Error when doing an explicit specilization within a class
2004-01-27 9:31 [Bug c++/13879] New: Error when doing an explicit specilization within a class lifshitz at post dot tau dot ac dot il
2004-01-27 15:35 ` [Bug c++/13879] " pinskia at gcc dot gnu dot org
@ 2004-01-28 5:58 ` lifshitz at post dot tau dot ac dot il
2004-01-28 6:05 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: lifshitz at post dot tau dot ac dot il @ 2004-01-28 5:58 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From lifshitz at post dot tau dot ac dot il 2004-01-28 05:58 -------
(In reply to comment #1)
> Not a bug, the error message is correct.
Is there a compilation flag that can help me compile it (without removing the
class)?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13879
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/13879] Error when doing an explicit specilization within a class
2004-01-27 9:31 [Bug c++/13879] New: Error when doing an explicit specilization within a class lifshitz at post dot tau dot ac dot il
2004-01-27 15:35 ` [Bug c++/13879] " pinskia at gcc dot gnu dot org
2004-01-28 5:58 ` lifshitz at post dot tau dot ac dot il
@ 2004-01-28 6:05 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-28 6:05 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-01-28 06:05 -------
Do this instead:
#include <stdio.h>
class Test {
public:
template<const int n>
struct Fact;
void Print();
};
template<const int n>
struct Test::Fact
{
enum {RET = Fact<n-1>::RET*n};
};
template<>
struct Test::Fact<0>
{
enum{RET = 1};
};
void Test::Print()
{
printf("Fact<7>=%d\n", Fact<7>::RET);
}
int main()
{
Test t;
t.Print();
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13879
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-01-28 6:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-27 9:31 [Bug c++/13879] New: Error when doing an explicit specilization within a class lifshitz at post dot tau dot ac dot il
2004-01-27 15:35 ` [Bug c++/13879] " pinskia at gcc dot gnu dot org
2004-01-28 5:58 ` lifshitz at post dot tau dot ac dot il
2004-01-28 6:05 ` pinskia at gcc dot gnu 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).