public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/10784: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)
@ 2003-05-15  4:47 bangerth
  0 siblings, 0 replies; 4+ messages in thread
From: bangerth @ 2003-05-15  4:47 UTC (permalink / raw)
  To: Serge.Bogdanov, gcc-bugs, gcc-prs, gdr, giovannibajo

Synopsis: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)

State-Changed-From-To: open->analyzed
State-Changed-By: bangerth
State-Changed-When: Thu May 15 04:47:45 2003
State-Changed-Why:
    I agree

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


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

* Re: c++/10784: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)
@ 2003-05-15  4:36 Gabriel Dos Reis
  0 siblings, 0 replies; 4+ messages in thread
From: Gabriel Dos Reis @ 2003-05-15  4:36 UTC (permalink / raw)
  To: gdr; +Cc: gcc-prs

The following reply was made to PR c++/10784; it has been noted by GNATS.

From: Gabriel Dos Reis <gdr@integrable-solutions.net>
To: giovannibajo@libero.it
Cc: Serge.Bogdanov@intel.com, gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org,
   giovannibajo@libero.it
Subject: Re: c++/10784: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)
Date: 15 May 2003 06:28:40 +0200

 giovannibajo@libero.it writes:
 
 | Synopsis: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)
 | 
 | Responsible-Changed-From-To: unassigned->gdr
 | Responsible-Changed-By: bajo
 | Responsible-Changed-When: Wed May 14 16:24:42 2003
 | Responsible-Changed-Why:
 |     Diagnostic mantainer. What do you think of this, Gaby?
 
 Yes, this sems to be a pointless warning.
 
 -- Gaby


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

* Re: c++/10784: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)
@ 2003-05-14 16:24 giovannibajo
  0 siblings, 0 replies; 4+ messages in thread
From: giovannibajo @ 2003-05-14 16:24 UTC (permalink / raw)
  To: Serge.Bogdanov, gcc-bugs, gcc-prs, gdr, giovannibajo, nobody

Synopsis: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)

Responsible-Changed-From-To: unassigned->gdr
Responsible-Changed-By: bajo
Responsible-Changed-When: Wed May 14 16:24:42 2003
Responsible-Changed-Why:
    Diagnostic mantainer. What do you think of this, Gaby?

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


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

* c++/10784: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)
@ 2003-05-14 16:16 giovannibajo
  0 siblings, 0 replies; 4+ messages in thread
From: giovannibajo @ 2003-05-14 16:16 UTC (permalink / raw)
  To: gcc-gnats; +Cc: Serge.Bogdanov


>Number:         10784
>Category:       c++
>Synopsis:       [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 14 16:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Giovanni Bajo
>Release:        3.0 -> 3.4
>Organization:
>Environment:
i686-pc-cygwin
>Description:
This was originally c++/4337, but I opened a new PR to make
it clearer.

--------------------------------
#include <stdio.h>

struct A {
};
struct A1 : public A {

    A1(const A &) {
        printf("A1(const A &)\n");
    }
    A1() {
        printf("A1()\n");
    }
};
A1 X;
struct A2 : public A {
    operator A1() {
        printf("operator A1()\n");
        return X;
    }
};

int main()
{
    A2 a2;
    A1 a1;
    a1 = a2;
}
--------------------------------
pr4337.cpp: In function `int main()':
pr4337.cpp:26: warning: choosing `A2::operator A1()' over `A1::A1(const A&)'
pr4337.cpp:26: warning:   for conversion from `A2' to `A1'
pr4337.cpp:26: warning:   because conversion sequence for the argument is better

GCC has always emitted the previous warning since at least
2.95. There is no (known?) way to turn it off, and it
breaks compilation. Besides, the code is not ambigous,
I think that the compiler should always select the custom
conversion operator, so there is nothing to warn about.
The output is:

A1()
A1()
operator A1()

and every compiler I have gives the same output.

Such a warning should be moved to -Wextra, if kept at all.
>How-To-Repeat:
Compile the above snippet.
>Fix:

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


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

end of thread, other threads:[~2003-05-15  4:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-15  4:47 c++/10784: [diagnostic] Warning about choosing custom operator over copy constructor cannot be turned off (and it's useless in the first place) bangerth
  -- strict thread matches above, loose matches on Subject: below --
2003-05-15  4:36 Gabriel Dos Reis
2003-05-14 16:24 giovannibajo
2003-05-14 16:16 giovannibajo

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