Path: utzoo!attcan!uunet!wuarchive!cs.utexas.edu!news-server.csri.toronto.edu!utgpu!cunews!bcars8!bnrgate!bigsur!news From: binky@bigsur.uucp (Glenn Langford) Newsgroups: comp.lang.c++ Subject: Spurious error: two initializers for Message-ID: <1990Aug3.141816.15829@bigsur.uucp> Date: 3 Aug 90 14:18:16 GMT Sender: news@bigsur.uucp (Usenet) Organization: Bell-Northern Research, Ottawa, Canada Lines: 78 I suspect the following is a Cfront 2.0 bug. Environment: Sun C++ 2.0, SparcStation 1, SunOS 4.0.3 I have included a sample program that illustrates the problem below. An incorrect error message is generated: error: two initializers for under certain conditions. The sample program defines two classes A and B. B is derived from A, and has two constructors. Both B constructors have initializers for the parent class. The 'two initializers' error is generated for B's second constructor. The error message only seems to appear when the translator has found a legitimate error earlier in the program. In the example code below, if the member function 'foo' is defined correctly, the program compiles ok. If 'foo' is seeded with an error, the 'two initializers' message appears. Comments? Is this a Cfront bug, or strictly a Sun C++ problem? Can someone try this with 2.1? Glenn Langford (Bell-Northern Research) Phone: (613) 763-8462 USENET: ...uunet!bnrgate!bigsur!binky binky@bnr.CA Mail: P.O. Box 3511, Station C, Ottawa, Ontario, Canada, K1Y 4H7 Spurn dogma. ---------------snip snip--------------------------------------------- class A { int a; public: A(int); void foo(int); }; class B : public A { int b; B(int); B(int,int); ~B(); // // USING THE FOLLOWING DEFINITION OF 'FOO' WILL COMPILE OK // // void foo(int t) { b = t;} // // USE THIS DEFINITION OF 'FOO' TO INDUCE THE SPURIOUS // 'TWO INITIALIZERS' ERROR // void foo(int t) { b = woops; } }; A::A(int x) { a = x; } B::B(int x, int y) : A(x) { b = y; } B::B(int x) : A(x) // <---- error: two initializers for A { b = x; } main() { } -- Glenn Langford (Bell-Northern Research) Phone: (613) 763-8462 USENET: ...uunet!bnrgate!bigsur!binky binky@bnr.CA Mail: P.O. Box 3511, Station C, Ottawa, Ontario, Canada, K1Y 4H7 If you never say anything significant, no disclaimer is required.