Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!casbah.acns.nwu.edu!nucsrl!tellab5!balr!clrcom!rmartin From: rmartin@clear.com (Bob Martin) Newsgroups: comp.lang.c++ Subject: Re: Bug in Sun C++ 2.0 Message-ID: <1991Mar23.023706.21574@clear.com> Date: 23 Mar 91 02:37:06 GMT References: <1991Mar21.022309.15355@clear.com> Organization: Clear Communications, Inc. Lines: 89 Bug in Sun CFont 2.0 -------------------- Sun Ref# 696308 Called in by Robert Martin. Abstract In a class with overloaded member function of the form: Add(type, ...); Only the first two declarations are recognized. Subsequent declarations do not seem to work if called with variable arguments. Example class X { public: X::X() {} void Add(int, ...) {}; void Add(long, ...) {}; void Add(double, ...) {}; }; main() { X x; x.Add(1, 1); x.Add(1L, 2); /*###16 [cc] error: ambiguous argument for X::Add(): void X::(int ... ) and void X::(long ... )%%%*/ /*###16 [cc] warning: double passed as int%%%*/ x.Add(1.2, 3); // fails. x.Add(1); x.Add(1L); x.Add(1.2); // works. } But if you swap the declarations around a bit. class X { public: X::X() {} void Add(double, ...) {}; // now double is first. void Add(int, ...) {}; void Add(long, ...) {}; }; main() { X x; x.Add(1, 1); /*###15 [cc] error: ambiguous argument for X::Add(): void X::(double ... ) and void X::(int ... )%%%*/ x.Add(1L, 2); // now it doesn't like longs. x.Add(1.2, 3); x.Add(1); x.Add(1L); // but this it can handle. x.Add(1.2); } So I conclude that the compiler is having trouble matching the signatures of member functions if those member functions are called with variable arguments. *********** Sun has acknowledged that this is indeed a bug, and that it has been fixed in version 2.1. +-Robert C. Martin-----+:RRR:::CCC:M:::::M:| Nobody is responsible for | | rmartin@clear.com |:R::R:C::::M:M:M:M:| my words but me. I want | | uunet!clrcom!rmartin |:RRR::C::::M::M::M:| all the credit, and all | +----------------------+:R::R::CCC:M:::::M:| the blame. So there. | -- +-Robert C. Martin-----+:RRR:::CCC:M:::::M:| Nobody is responsible for | | rmartin@clear.com |:R::R:C::::M:M:M:M:| my words but me. I want | | uunet!clrcom!rmartin |:RRR::C::::M::M::M:| all the credit, and all | +----------------------+:R::R::CCC:M:::::M:| the blame. So there. |