This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
g++ parser bug?
- To: gcc-bugs at gcc dot gnu dot org
- Subject: g++ parser bug?
- From: James Lewis Nance <jlnance at worldnet dot att dot net>
- Date: Thu, 23 Mar 2000 17:19:22 -0500
Hello All,
I think I may have found a bug in the g++ parser. I dont know C++ well
enough to know if this should compile, but it does compile and run on 2
other c++ compilers (MRI & Digital Unix). It fails on gcc-2.95.2,
gcc-2.8.something, and Mike Shaver reported that it failed on the most
recent gcc snapshot. My coworker, Bill Gutknecht, came up with this
minimal testcase to demonstrate the problem.
Thanks,
Jim
extern "C" int printf(const char*, ...);
class a {
friend class c;
public:
a() : data(10)
{ printf("constructor a\n"); };
private:
int data;
};
class c {
public:
c(const a & arg)
{ printf("constructor c arg.data = %d \n",arg.data); };
c(const a & arg, int arg2)
{ printf("constructor c arg.data = %d arg2 = %d\n",arg.data,arg2); };
};
main()
{
c foo1(a()); // Compiles & runs, but does not do anything
c foo2((class a) a()); // Compiles, and runs properly
c foo3(a(),1); // Does not compile (must be barfing on the "1")
c foo4((class a) a(),1); // Compiles and runs properly
}