public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10380: warning about "choosing ... over ..." when there is no choice
@ 2003-04-20 13:39 nathan
  0 siblings, 0 replies; 3+ messages in thread
From: nathan @ 2003-04-20 13:39 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, lehn, nobody, stip

Synopsis: warning about "choosing ... over ..." when there is no choice

State-Changed-From-To: analyzed->closed
State-Changed-By: nathan
State-Changed-When: Sun Apr 20 13:39:39 2003
State-Changed-Why:
    not a bug. a = c, is equivalent to a.operator= (c)
    The candidate function is A::operator=(A const &)
    There are two user-defined conversion sequences to convert
    'c' to 'A const &', these are
    1) const qualify C, apply C::operator A () const
    2) apply C::operator B (), convert to A const &
    these are indistinguishable conversion sequences, and 
    therefore the call is ill-formed. G++ is not so picky about
    things, and finds a conversion that works, but might not be the one you expected.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10380


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: c++/10380: warning about "choosing ... over ..." when there is no choice
@ 2003-04-11 19:44 bangerth
  0 siblings, 0 replies; 3+ messages in thread
From: bangerth @ 2003-04-11 19:44 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, lehn, nobody, stip

Synopsis: warning about "choosing ... over ..." when there is no choice

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Fri Apr 11 19:44:54 2003
State-Changed-Why:
    Confirmed. Essentially a duplicate of 10337, but with
    slightly different code.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=10380


^ permalink raw reply	[flat|nested] 3+ messages in thread

* c++/10380: warning about "choosing ... over ..." when there is no choice
@ 2003-04-11 19:16 stip
  0 siblings, 0 replies; 3+ messages in thread
From: stip @ 2003-04-11 19:16 UTC (permalink / raw)
  To: gcc-gnats; +Cc: lehn


>Number:         10380
>Category:       c++
>Synopsis:       warning about "choosing ... over ..." when there is no choice
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 11 19:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     stip@mathematik.uni-ulm.de
>Release:        unknown-1.0
>Organization:
>Environment:
gcc 3.2 on Solaris 2.9
>Description:
gcc produces warning about chosing one conversion operator over another in the following example where there is only one correct choice:

struct A
{
};

struct B : public A
{
};

class C {
    public:
        operator A() const { return A(); }
        operator B() { return B(); }
};

int
main()
{
    C c;

    A a;
    B b;

    a = c;
    b = c;

    return 0;
}

According to the standard IMO there is no reason to complain but the second conversion operator B() has
to be chosen in both assignments. There is no way to (correctly) apply the first conversion operator, so why
warning about the possibility?
There is no switch to turn exactly this warning off what makes it even worse.
>How-To-Repeat:
g++ 
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-04-20 13:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-20 13:39 c++/10380: warning about "choosing ... over ..." when there is no choice nathan
  -- strict thread matches above, loose matches on Subject: below --
2003-04-11 19:44 bangerth
2003-04-11 19:16 stip

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).