public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/34124] New: auto_ptr ambiguous conversion
@ 2007-11-16 19:55 cfekete1 at gmail dot com
2007-11-16 20:26 ` [Bug c++/34124] " pcarlini at suse dot de
2008-01-25 20:37 ` [Bug libstdc++/34124] " pcarlini at suse dot de
0 siblings, 2 replies; 3+ messages in thread
From: cfekete1 at gmail dot com @ 2007-11-16 19:55 UTC (permalink / raw)
To: gcc-bugs
Hi,
Running the following code:
#include <memory>
using namespace std;
class CBase {};
class CDerived : public CBase {};
void Set(auto_ptr<CBase> base)
{
}
int main(int argc, char *argv[])
{
auto_ptr<CDerived> derived(new CDerived);
Set(derived); // error: conversion from 'std::auto_ptr<CDerived>' to
'std::auto_ptr<CBase>' is ambiguous
auto_ptr<CBase> base(derived); // but this is OK
base = derived; // this is OK too
}
the Set(derived) gives the mentioned error in the comment. The next two lines
compiles without error so both the copy constructor and the operator= of
auto_ptr works fine. But for some reason the conversion is ambiguous if a
function (in this case Set) is called.
In the next two lines of the compiler output, there are two notes:
/usr/include/c++/4.2.1/memory:368: note: candidates are:
std::auto_ptr<_Tp>::operator std::auto_ptr<_Tp1>() [with _Tp1 = CBase, _Tp =
CDerived]
/usr/include/c++/4.2.1/memory:212: note:
std::auto_ptr<_Tp>::auto_ptr(std::auto_ptr<_Tp1>&) [with _Tp1 = CDerived, _Tp =
CBase]
Please could you check if this is a bug or I made something wrong?
Thanks,
Csaba
--
Summary: auto_ptr ambiguous conversion
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: cfekete1 at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34124
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/34124] auto_ptr ambiguous conversion
2007-11-16 19:55 [Bug c++/34124] New: auto_ptr ambiguous conversion cfekete1 at gmail dot com
@ 2007-11-16 20:26 ` pcarlini at suse dot de
2008-01-25 20:37 ` [Bug libstdc++/34124] " pcarlini at suse dot de
1 sibling, 0 replies; 3+ messages in thread
From: pcarlini at suse dot de @ 2007-11-16 20:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pcarlini at suse dot de 2007-11-16 20:26 -------
*** Bug 34125 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34124
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug libstdc++/34124] auto_ptr ambiguous conversion
2007-11-16 19:55 [Bug c++/34124] New: auto_ptr ambiguous conversion cfekete1 at gmail dot com
2007-11-16 20:26 ` [Bug c++/34124] " pcarlini at suse dot de
@ 2008-01-25 20:37 ` pcarlini at suse dot de
1 sibling, 0 replies; 3+ messages in thread
From: pcarlini at suse dot de @ 2008-01-25 20:37 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pcarlini at suse dot de 2008-01-25 20:31 -------
There isn't much to say: both the templated constructor and the templated
conversion operator must be there per the current C++ standard, and your code
cannot compile. Note that, in general, the design of auto_ptr is considered
seriously broken and therefore it will be deprecated for the next standard and
unique_ptr provided as replacement.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34124
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-01-25 20:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-16 19:55 [Bug c++/34124] New: auto_ptr ambiguous conversion cfekete1 at gmail dot com
2007-11-16 20:26 ` [Bug c++/34124] " pcarlini at suse dot de
2008-01-25 20:37 ` [Bug libstdc++/34124] " pcarlini at suse dot de
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).