From -7613410201650470047
X-Google-Thread: f78e5,8983dbb7c598f774,start
X-Google-Attributes: gidf78e5,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.hanau.net!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull
From: rogero@howzatt.demon.co.uk ("Roger Orr")
Newsgroups: comp.std.c++
Subject: Ambiguous conversion to base?
Date: Sun, 30 Jul 2006 05:02:10 GMT
Lines: 47
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <eag3it$5qn$1$8302bc10@news.demon.co.uk>
NNTP-Posting-Host: news.news.demon.net
X-Trace: news.demon.co.uk 1154235735 18229 158.152.254.254 (30 Jul 2006 05:02:15 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sun, 30 Jul 2006 05:02:15 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.504
X-Greylisting: NO DELAY (Relay+Sender autoqualified);
	processed by UCSD_GL-v2.1 on mailbox7.ucsd.edu;
	Sat, 29 July 2006 09:49:37 -0700 (PDT)
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-MSMail-Priority: Normal
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.6+Sun/8.13.6/Submit) id k6U52Atd018730;
	Sun, 30 Jul 2006 15:02:10 +1000 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
X-NNTP-Posting-Date: Sat, 29 Jul 2006 16:49:34 +0000 (UTC)
X-Delivered-To: std-c++@mailman.ucar.edu
X-Spamscanner: mailbox7.ucsd.edu  (v1.6 Jul  6 2006 16:38:12, -0.0/5.0 3.1.3)
X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f
X-Newsreader: Microsoft Outlook Express 6.00.3790.504
X-Newsgroups: comp.std.c++
X-MailScanner: PASSED (v1.2.8 6713 k6TGnZLV014948 mailbox7.ucsd.edu)
Xref: g2news2.google.com comp.std.c++:3125

Should this fragment compile?

class Base
{
};

class Derived : public Base
{
public:
   Derived( Derived const & );
   Derived( Base const ); // Note: no '&'
};

class Final : public Derived
{
   Final( Final const & f )
   : Derived( f ) {}
};

MSVC 2003 and Comeau say 'Yes'
g++ 3.4.4 and 4.0.2 say 'No':

copyctor.cpp: In copy constructor `Final::Final(const Final&)':
copyctor.cpp:15: error: call of overloaded `Derived(const Final&)' is
ambiguous
copyctor.cpp:9: note: candidates are: Derived::Derived(Base)
copyctor.cpp:8: note:  Derived::Derived(const Derived&)

As far as I understand it conversion from Final const & -> Derived const &
should be a better conversion than any conversion to Base.
Or have I missed something?

[ Yes, I know the code fragment exbihits dubious programming practices but I
want to know if it is legal :-) ]

TIA,
Roger Orr
--
MVP in C++ at www.brainbench.com


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]



