This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/3601: GCC 3.0 barfs on overloaded operator==



>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=


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]