Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@sourceware.cygnus.com>
List-Archive: <http://sourceware.cygnus.com/ml/cygwin/>
List-Post: <mailto:cygwin@sourceware.cygnus.com>
List-Help: <mailto:cygwin-help@sourceware.cygnus.com>, <http://sourceware.cygnus.com/ml/#faqs>
Sender: cygwin-owner@sourceware.cygnus.com
Delivered-To: mailing list cygwin@sourceware.cygnus.com
X-Authentication-Warning: hp2.xraylith.wisc.edu: khan owned process doing -bs
Date: Tue, 8 Feb 2000 10:03:47 -0600 (CST)
From: Mumit Khan <khan@NanoTech.Wisc.EDU>
To: "K. Haley" <khaley@bigfoot.com>
cc: cygwin@sourceware.cygnus.com
Subject: Re: Overloaded constructor resolution
In-Reply-To: <4.2.2.20000207195446.00a3c7d0@pop.mail.yahoo.com>
Message-ID: <Pine.HPP.3.96.1000208095828.4570G-100000@hp2.xraylith.wisc.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

On Mon, 7 Feb 2000, K. Haley wrote:

> I'm trying to compile some library code with GCC 2.95.2 but I keep getting 
> an ambiguous constructor call.  Here is the error:
> 
> gauge.cpp: In method `void OWL::TGauge::SetBkgndColor(const OWL::TColor &)':
> gauge.cpp:217: call of overloaded `TColor(unsigned int)' is ambiguous
> ../../Include/owl/color.h:458: candidates are: OWL::TColor::TColor(const 
> OWL::TColor &) <near match>
> ../../Include/owl/color.h:468:                 OWL::TColor::TColor(long 
> unsigned int)
> ../../Include/owl/color.h:478:                 OWL::TColor::TColor(long int)
> ../../Include/owl/color.h:509:                 OWL::TColor::TColor(short int)
> make: *** [../../Obj/owlwfg/gauge.obj] Error 1
> 
> I've fixed the offending code with a cast, but I'm wondering why other 
> compilers don't complain.  This code has been compiled with Borland and MS 
> compilers.

From the message, your code is simply ambiguous and needs a cast. I don't
know why MS and Borland accept it, but KAI, GCC etc don't. Here's a
trivial testcase:

    struct foo
    {
      foo (long unsigned int);
      foo (long int);
      foo (short int);
    };

    void
    bar ()
    {
      foo foo1 (5); // <<< Hmmm ... which one?
    }

You could always try out Comeau's online compiler (it's based on the EDG
front-end like KCC and one of the most standard conforming out there) at
http://www.comeaucomputing.com/tryitout/

If you feel it's a bug, please post a testcase to gcc-bugs@gcc.gnu.org.

Regards,
mUmit



--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

