This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/3601: GCC 3.0 barfs on overloaded operator==
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/3601: GCC 3.0 barfs on overloaded operator==
- From: markus_schoder at yahoo dot de
- Date: 7 Jul 2001 05:03:12 -0000
- Reply-To: markus_schoder at yahoo dot de
>Number: 3601
>Category: c++
>Synopsis: GCC 3.0 barfs on overloaded operator==
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Fri Jul 06 22:06:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Markus Schoder
>Release: gcc-3.0 gcc-3.0-20010626
>Organization:
>Environment:
Linux i386
>Description:
Compilation of the attached program gives the following error:
eqtempl.cpp: In function `bool g(A)':
eqtempl.cpp:14: choosing `bool operator==(A, void*)' over `operator=='
eqtempl.cpp:14: because worst conversion for the former is better than worst
conversion for the latter
I do not see how there is a conversion involved for bool operator==(A, void*). 0 needs not be "converted" to void* in C++. However with an explicit conversion to void* it compiles.
It also compiles when -fpermissive is given as an option but this should not be needed.
>How-To-Repeat:
Compile attached program (without linking)
>Fix:
A workaround is to use an explicit cast like:
a == (void*)0
or specify -fpermissive as a command line option.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="eqtempl.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="eqtempl.cpp"
c3RydWN0IEEKewogIG9wZXJhdG9yIGJvb2woKSB7IHJldHVybiBwOyB9OwogIHZvaWQgKnA7Cn07
Cgpib29sIG9wZXJhdG9yPT0oQSB4LCB2b2lkICp5KQp7CiAgcmV0dXJuIHgucCA9PSB5Owp9Cgpi
b29sIGcoQSBhKQp7CiAgcmV0dXJuIGEgPT0gMDsKfQo=