This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

g++ parser bug?


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

}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]