This is the mail archive of the 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
>Originator:     Markus Schoder
>Release:        gcc-3.0 gcc-3.0-20010626
Linux i386
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.
Compile attached program (without linking)
A workaround is to use an explicit cast like:

a == (void*)0

or specify -fpermissive as a command line option.
Content-Type: text/x-c++src; name="eqtempl.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="eqtempl.cpp"


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