This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
gcc2.95 fails to compile correct code
- To: gcc-bugs at gcc dot gnu dot org
- Subject: gcc2.95 fails to compile correct code
- From: V Lakshman <lakshmanok at netscape dot net>
- Date: 30 Jul 99 12:26:18 PDT
- CC: lakshman at nssl dot noaa dot gov
This source code compiles fine using gcc 2.91 but not with 2.95
Please respond either to lakshman@nssl.noaa.gov or directly to
the newsgroup; I never read email here, but am using this because
my mailserver is blocked by ORBS.
g++ 2.95 reports that:
tmpl.cc:7: using template type parameter `X' after `class'
stholly:tmpl_bug% /usr/test/bin/g++ -v
Reading specs from /usr/test/lib/gcc-lib/sparc-sun-solaris2.7/2.95/specs
gcc version 2.95 19990728 (release)
stholly:tmpl_bug% /usr/local/bin/g++ -v
Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/egcs-2.91.60/specs
gcc version egcs-2.91.60 19981201 (egcs-1.1.1 release)
Source code follows:
#include <iostream>
template< class X >
class Counter
{
public:
friend class X; // 2.95 fails to compile this line
Counter() : d_num(0) {}
private:
int d_num;
}
;
class Thing
{
public:
static Counter<Thing> h;
int num() const
{
return h.d_num;
}
Thing()
{
h.d_num ++;
}
}
;
Counter<Thing> Thing::h;
int main()
{
Thing temp;
std::cout << temp.num() << "\n";
for (int i=0; i<100; ++i)
temp = Thing();
std::cout << temp.num() << "\n";
}
____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at http://webmail.netscape.com.